Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,12 @@ Lambda.prototype._rsync = function (program, src, dest, excludeNodeModules, call
return callback(err);
}

// include package.json unless prebuiltDirectory is set
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.
exec('rsync -rL ' + excludeArgs + ' ' + src.trim() + '/ ' + dest, function (err) {
exec('rsync -rL ' + includeArgs + excludeArgs + ' ' + src.trim() + '/ ' + dest, function (err) {
if (err) {
return callback(err);
}
Expand Down
33 changes: 33 additions & 0 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,39 @@ describe('node-lambda', function () {
done();
});
});

it('rsync should not exclude package.json, even when excluded by excludeGlobs', function (done) {
program.excludeGlobs="*.json"
lambda._rsync(program, '.', codeDirectory, true, function(err, result) {
var contents = fs.readdirSync(codeDirectory);
result = _.includes(contents, 'package.json');
assert.equal(result, true);

done();
});
});

it('rsync should not include package.json when --prebuiltDirectory is set', function (done) {
var path = '.build_' + Date.now();
after(function() {
rimraf.sync(path, fs);
});

fs.mkdirSync(path);
fs.writeFileSync(path + '/testa');
fs.writeFileSync(path + '/package.json');

program.excludeGlobs = "*.json"
program.prebuiltDirectory = path;
lambda._rsync(program, path, codeDirectory, true, function(err, result) {
var contents = fs.readdirSync(codeDirectory);
result = !_.includes(contents, 'package.json') &&
_.includes(contents, 'testa');
assert.equal(result, true);

done();
});
});
});
});

Expand Down