Skip to content

Commit

Permalink
Fix to include only package.json in the source directory (#274)
Browse files Browse the repository at this point in the history
* Fix to include only `package.json` in the source directory

* Modify to `===` comparison
  • Loading branch information
abetomo authored and DeviaVir committed May 11, 2017
1 parent bb0e951 commit b558c3b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ Lambda.prototype._fileCopy = function (program, src, dest, excludeNodeModules, c
const options = {
dereference: true, // same meaning as `-L` of `rsync` command
filter: function (src, dest) {
if (!program.prebuiltDirectory && path.basename(src) == 'package.json') {
if (!program.prebuiltDirectory && src === path.join(srcAbsolutePath, 'package.json')) {
// include package.json unless prebuiltDirectory is set
return true;
}
Expand Down Expand Up @@ -272,7 +272,7 @@ Lambda.prototype._rsync = function (program, src, dest, excludeNodeModules, call
}

// include package.json unless prebuiltDirectory is set
var includeArgs = program.prebuiltDirectory ? '' : '--include package.json ';
var includeArgs = program.prebuiltDirectory ? '' : '--include /package.json ';

// we need the extra / after src to make sure we are copying the content
// of the directory, not the directory itself.
Expand Down
1 change: 1 addition & 0 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ describe('node-lambda', function () {
fs.mkdirsSync(path.join('__unittest', 'hoge'));
fs.mkdirsSync(path.join('__unittest', 'fuga'));
fs.writeFileSync(path.join('__unittest', 'hoge', 'piyo'));
fs.writeFileSync(path.join('__unittest', 'hoge', 'package.json'));
fs.writeFileSync('fuga');
});
after(function () {
Expand Down

0 comments on commit b558c3b

Please sign in to comment.