-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix to include only package.json
in the source directory
#274
Fix to include only package.json
in the source directory
#274
Conversation
@@ -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')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The setting to exclude __unittest/hoge/*
is https://github.com/motdotla/node-lambda/pull/274/files#diff-e5b8495db5b34b144973178386ba5ceeR247.
lib/main.js
Outdated
@@ -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')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
===
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -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 '; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure, but the /
would make the path invalid, or no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The include
and exclude
options of rsync are complicated, so I can not explain the exact behavior, but the result was as follows.
src directory
% pwd
/tmp/test
% find /tmp/test -type f
/tmp/test/package.json
/tmp/test/foo/package.json
exclude='foo/*'
include='package.json'
% rm -rf /tmp/bar; rsync -rL --include='package.json' --exclude='foo/*' /tmp/test /tmp/bar
% find /tmp/bar -type f
/tmp/bar/test/package.json
/tmp/bar/test/foo/package.json
include='/package.json'
% rm -rf /tmp/bar; rsync -rL --include='/package.json' --exclude='foo/*' /tmp/test /tmp/bar
% find /tmp/bar -type f
/tmp/bar/test/package.json
exclude='foo'
include='package.json'
% rm -rf /tmp/bar; rsync -rL --include='package.json' --exclude='foo' /tmp/test /tmp/bar
% find /tmp/bar -type f
/tmp/bar/test/package.json
include='/package.json'
% rm -rf /tmp/bar; rsync -rL --include='/package.json' --exclude='foo' /tmp/test /tmp/bar
% find /tmp/bar -type f
/tmp/bar/test/package.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
#272
I restricted
package.json
, but is there any adverse effect you are concerned about?