From 205b8be7d12b3453584c13c80f61d3061a782025 Mon Sep 17 00:00:00 2001 From: abetomo Date: Wed, 10 May 2017 21:49:44 +0900 Subject: [PATCH 1/2] Fix to include only `package.json` in the source directory --- lib/main.js | 4 ++-- test/main.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index cb1b667b..f09dc166 100644 --- a/lib/main.js +++ b/lib/main.js @@ -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; } @@ -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. diff --git a/test/main.js b/test/main.js index e13913f5..6ce9b577 100644 --- a/test/main.js +++ b/test/main.js @@ -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 () { From d77cc3989ad368be00ba8d8158d7c6fdcb55bb09 Mon Sep 17 00:00:00 2001 From: abetomo Date: Thu, 11 May 2017 09:42:57 +0900 Subject: [PATCH 2/2] Modify to `===` comparison --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index f09dc166..fdc7ea10 100644 --- a/lib/main.js +++ b/lib/main.js @@ -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 && src == path.join(srcAbsolutePath, 'package.json')) { + if (!program.prebuiltDirectory && src === path.join(srcAbsolutePath, 'package.json')) { // include package.json unless prebuiltDirectory is set return true; }