diff --git a/Gruntfile.js b/Gruntfile.js index 8186e73..5c3b451 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -62,6 +62,7 @@ module.exports = function (grunt) { options: { dist_folder: 'tmp/dist', include_time: false, + include_version: false, package_folder: 'test/fixtures/package_custom', include_files: ['custom.json'] } diff --git a/README.md b/README.md index 5c84bc3..d81fe4f 100644 --- a/README.md +++ b/README.md @@ -196,12 +196,19 @@ Default value: `[]` List of files to explicitly include in the package, even if they would be ignored by NPM +##### options.include_version +Type: `Boolean` +Default value: `true` + +Whether or not to add version the packages, if set to true the version from the package.json will be included in the zip name, if false + then the package name will be constant and consist of just the package name and (time if options.include_time). + ##### options.include_time Type: `Boolean` Default value: `true` Whether or not to timestamp the packages, if set to true the current date/time will be included in the zip name, if false - then the package name will be constant and consist of just the package name and version. + then the package name will be constant and consist of just the package name and (version if options.include_version). ##### options.package_folder Type: `String` @@ -536,4 +543,4 @@ Adding more warnings for various failure cases ### 0.11.0 * Including AWS API error message in deployment failure - [pull request by CaseyBurns](https://github.com/Tim-B/grunt-aws-lambda/pull/40) * Providing a method to pass AWS credentials in either the Gruntfile or credentials file - [pull request by robbiet480](https://github.com/Tim-B/grunt-aws-lambda/pull/34) -* Adding support for AWS temporary credentials - [pull request by olih](https://github.com/Tim-B/grunt-aws-lambda/pull/46) \ No newline at end of file +* Adding support for AWS temporary credentials - [pull request by olih](https://github.com/Tim-B/grunt-aws-lambda/pull/46) diff --git a/tasks/lambda_package.js b/tasks/lambda_package.js index 19ae916..f35addf 100644 --- a/tasks/lambda_package.js +++ b/tasks/lambda_package.js @@ -28,6 +28,7 @@ module.exports = function (grunt) { var options = this.options({ 'dist_folder': 'dist', 'include_time': true, + 'include_version': true, 'package_folder': './', 'include_files': [] }); @@ -38,7 +39,11 @@ module.exports = function (grunt) { var done = this.async(); var now = new Date(); - var time_string = 'latest'; + var archive_name = pkg.name; + + if (options.include_version) { + archive_name += '_' + pkg.version.replace(/\./g, '-') + } if (options.include_time) { var time_components = [ @@ -49,12 +54,9 @@ module.exports = function (grunt) { now.getMinutes(), now.getSeconds() ]; - time_string = time_components.join('-'); - } - - var file_version = pkg.version.replace(/\./g, '-'); - var archive_name = pkg.name + '_' + file_version + '_' + time_string; + archive_name += '_' + time_components.join('-'); + } npm.load([], function (err, npm) { diff --git a/test/lambda_package_test.js b/test/lambda_package_test.js index 2f76d31..e71a639 100644 --- a/test/lambda_package_test.js +++ b/test/lambda_package_test.js @@ -60,7 +60,7 @@ exports.lambda_package = { }, custom_options: function (test) { test.expect(6); - var zip = new AdmZip("tmp/dist/another-lambda-function_0-0-1_latest.zip"); + var zip = new AdmZip("tmp/dist/another-lambda-function.zip"); var zipEntries = zip.getEntries(); var required = [