Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ module.exports = function(S) {

const path = require('path'),
_ = require('lodash'),
fs = require('fs'),
fs = require('fs-extra'),
browserify = require('browserify'),
UglifyJS = require('uglify-js'),
wrench = require('wrench'),
BbPromise = require('bluebird');

/**
Expand Down Expand Up @@ -270,16 +269,11 @@ module.exports = function(S) {
let destPath = path.join(_this.optimizedDistPath, p);

if (fs.lstatSync(p).isDirectory()) {
wrench.mkdirSyncRecursive(destPath, '0777');
wrench.copyDirSyncRecursive(
path.join(_this.evt.options.pathDist, p),
destPath, {
forceDelete: true
}
);
fs.mkdirsSync(destPath, '0777');
fs.copySync(path.join(_this.evt.options.pathDist, p), destPath, {clobber: true, dereference: true});
} else {
wrench.mkdirSyncRecursive(path.dirname(destPath), '0777');
S.utils.writeFileSync(destPath, S.utils.readFileSync(p));
fs.mkdirsSync(path.dirname(destPath), '0777');
fs.copySync(p, destPath, {clobber: true, dereference: true});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the link I posted in the other task, the dereference option is only supported for the fs-extra.copy and not the fs-extra.copySync. I would suggest to use the asynchronous variant here, maybe wrapped by a Promise.fromCallback() to have a promisified implementation.
See also here: jprichardson/node-fs-extra#210

}
});
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serverless-optimizer-plugin",
"version": "2.1.0",
"version": "2.1.1",
"engines": {
"node": ">=4.0"
},
Expand Down Expand Up @@ -41,6 +41,6 @@
"browserify": "^13.0.0",
"lodash": "^4.0.0",
"uglify-js": "^2.6.1",
"wrench": "^1.5.8"
"fs-extra": "~0.26.7"
}
}