Skip to content
Closed
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
1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']
}
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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)
* Adding support for AWS temporary credentials - [pull request by olih](https://github.com/Tim-B/grunt-aws-lambda/pull/46)
14 changes: 8 additions & 6 deletions tasks/lambda_package.js
Original file line number Diff line number Diff line change
Expand Up @@ -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': []
});
Expand All @@ -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 = [
Expand All @@ -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) {

Expand Down
2 changes: 1 addition & 1 deletion test/lambda_package_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down