diff --git a/lib/main.js b/lib/main.js index cb1b667b..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 && 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 () {