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
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();
}

};