Skip to content

Commit 4997c4c

Browse files
committed
Merge pull request #10 from ember-cli-deploy/revert-keep-change-pending-tests
Revert "Add keep option" pending a fresh PR with tests
2 parents 1227681 + 55f89da commit 4997c4c

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,6 @@ If set to `true`, you will need to `npm install node-zopfli --save-dev` in your
7878

7979
*Default:* `false`
8080

81-
### keep
82-
83-
Keep original file and write compressed data to `originalFile.gz`
84-
85-
*Default:* `false`
86-
8781
## Prequisites
8882

8983
The following properties are expected to be present on the deployment `context` object:
@@ -103,3 +97,8 @@ The following properties are expected to be present on the deployment `context`
10397
[1]: http://ember-cli.github.io/ember-cli-deploy/plugins "Plugin Documentation"
10498
[2]: https://github.com/zapnito/ember-cli-deploy-build "ember-cli-deploy-build"
10599
[3]: https://github.com/zapnito/ember-cli-deploy-s3 "ember-cli-deploy-s3"
100+
101+
## TODO
102+
103+
Some deployment flows require side-by-side deployment of compressed and uncompressed
104+
assets. A PR to add this option would be welcome.

index.js

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ module.exports = {
2222
defaultConfig: {
2323
filePattern: '**/*.{js,css,png,gif,ico,jpg,map,xml,txt,svg,swf,eot,ttf,woff,woff2}',
2424
zopfli: false,
25-
keep: false,
2625
distDir: function(context){
2726
return context.distDir;
2827
},
@@ -47,28 +46,26 @@ module.exports = {
4746
var filePattern = this.readConfig('filePattern');
4847
var distDir = this.readConfig('distDir');
4948
var distFiles = this.readConfig('distFiles') || [];
50-
var keep = this.readConfig('keep');
5149

5250
this.log('gzipping `' + filePattern + '`');
53-
return this._gzipFiles(distDir, distFiles, filePattern, keep)
51+
return this._gzipFiles(distDir, distFiles, filePattern)
5452
.then(function(gzippedFiles) {
5553
self.log('gzipped ' + gzippedFiles.length + ' files ok');
5654
return { gzippedFiles: gzippedFiles };
5755
})
5856
.catch(this._errorMessage.bind(this));
5957
},
60-
_gzipFiles: function(distDir, distFiles, filePattern, keep) {
58+
_gzipFiles: function(distDir, distFiles, filePattern, gzipLibrary) {
6159
var filesToGzip = distFiles.filter(minimatch.filter(filePattern, { matchBase: true }));
62-
return Promise.map(filesToGzip, this._gzipFile.bind(this, distDir, keep));
60+
return Promise.map(filesToGzip, this._gzipFileInPlace.bind(this, distDir));
6361
},
64-
_gzipFile: function(distDir, keep, filePath) {
62+
_gzipFileInPlace: function(distDir, filePath) {
6563
var self = this;
6664
var fullPath = path.join(distDir, filePath);
67-
var outFilePath = fullPath + '.gz';
6865
return new Promise(function(resolve, reject) {
6966
var gzip = self.gzipLibrary.createGzip({ format: 'gzip' });
7067
var inp = fs.createReadStream(fullPath);
71-
var out = fs.createWriteStream(outFilePath);
68+
var out = fs.createWriteStream(fullPath + '.gz');
7269

7370
inp.pipe(gzip).pipe(out);
7471
inp.on('error', function(err){
@@ -81,14 +78,10 @@ module.exports = {
8178
resolve();
8279
});
8380
}).then(function(){
84-
if(!keep) {
85-
outFilePath = fullPath;
86-
return renameFile(fullPath + '.gz', fullPath);
87-
}
81+
return renameFile(fullPath + '.gz', fullPath);
8882
}).then(function(){
89-
self.log('✔ ' + outFilePath);
90-
91-
return outFilePath;
83+
self.log('✔ ' + filePath);
84+
return filePath;
9285
});
9386
},
9487
_errorMessage: function(error) {

0 commit comments

Comments
 (0)