Skip to content

Commit

Permalink
Merge pull request #19 from dhleong/dhleong/IncludeFilesOption
Browse files Browse the repository at this point in the history
Add `include_files` option to lambda_package
  • Loading branch information
Tim-B committed Jul 12, 2015
2 parents 748308f + e4451fc commit 9d168b3
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.idea
*.iml
tmp
tmp
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ module.exports = function (grunt) {
options: {
dist_folder: 'tmp/dist',
include_time: false,
package_folder: 'test/fixtures/package_custom'
package_folder: 'test/fixtures/package_custom',
include_files: ['custom.json']
}
}
},
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ grunt.initConfig({

#### Options

##### options.include_files
Type: `Array`
Default value: `[]`

List of files to explicitly include in the package, even if they would be ignored by NPM

##### options.include_time
Type: `Boolean`
Default value: `true`
Expand Down
14 changes: 13 additions & 1 deletion tasks/lambda_package.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ module.exports = function (grunt) {
var options = this.options({
'dist_folder': 'dist',
'include_time': true,
'package_folder': './'
'package_folder': './',
'include_files': []
});

var pkg = grunt.file.readJSON(path.resolve(options.package_folder + '/package.json'));
Expand Down Expand Up @@ -91,6 +92,17 @@ module.exports = function (grunt) {
}
]);

if (options.include_files.length) {
zipArchive.bulk([
{
src: options.include_files,
dot: true,
expand: true,
cwd: options.package_folder
}
]);
}

zipArchive.finalize();

output.on('close', function () {
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/package_custom/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom.json
1 change: 1 addition & 0 deletions test/fixtures/package_custom/custom.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 3 additions & 1 deletion test/lambda_package_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ exports.lambda_package = {
});
},
custom_options: function (test) {
test.expect(5);
test.expect(6);
var zip = new AdmZip("tmp/dist/another-lambda-function_0-0-1_latest.zip");
var zipEntries = zip.getEntries();

var required = [
'custom.json',
'index.js',
'package.json',
'node_modules/',
Expand All @@ -79,4 +80,5 @@ exports.lambda_package = {

test.done();
}

};

0 comments on commit 9d168b3

Please sign in to comment.