Skip to content
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

Merged
merged 2 commits into from
May 11, 2017

Conversation

abetomo
Copy link
Contributor

@abetomo abetomo commented May 10, 2017

#272

I restricted package.json, but is there any adverse effect you are concerned about?

@@ -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'));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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')) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

===?

Copy link
Contributor Author

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 ';
Copy link
Collaborator

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?

Copy link
Contributor Author

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

Copy link
Collaborator

@DeviaVir DeviaVir left a comment

Choose a reason for hiding this comment

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

👍

@DeviaVir DeviaVir merged commit b558c3b into motdotla:master May 11, 2017
@abetomo abetomo deleted the bugfix_exclude_package_json branch May 11, 2017 07:33
@DeviaVir DeviaVir mentioned this pull request Jun 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants