grunt-aws-lambda
Advanced tools
Comparing version 0.4.0 to 0.5.0
{ | ||
"name": "grunt-aws-lambda", | ||
"description": "A grunt plugin to help develop AWS Lambda functions.", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"homepage": "https://github.com/Tim-B/grunt-aws-lambda", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -479,1 +479,7 @@ # grunt-aws-lambda | ||
* Bumped adm-zip version, will hopefully address [issue 4](https://github.com/Tim-B/grunt-aws-lambda/issues/4) | ||
### 0.5.0 | ||
* Fixed issue where dotfiles weren't packaged - [see issue 17](https://github.com/Tim-B/grunt-aws-lambda/issues/17) | ||
* Fixed issue where task could be done before zip writing is finished - [pull request by qen](https://github.com/Tim-B/grunt-aws-lambda/pull/16) | ||
* Monkey patched node-archiver to force permissions to be 777 for all files in package - [see issue 6](https://github.com/Tim-B/grunt-aws-lambda/issues/6) | ||
@@ -15,5 +15,5 @@ /* | ||
var npm = require("npm"); | ||
var tmp = require('temporary'); | ||
var archive = require('archiver'); | ||
var fs = require('fs'); | ||
var tmp = require('temporary'); | ||
var mkdirp = require('mkdirp'); | ||
@@ -44,3 +44,11 @@ var rimraf = require('rimraf'); | ||
if (options.include_time) { | ||
time_string = now.getFullYear() + '-' + now.getMonth() + '-' + now.getDate() + '-' + now.getHours() + '-' + now.getMinutes() + '-' + now.getSeconds(); | ||
var time_components = [ | ||
now.getFullYear(), | ||
now.getMonth(), | ||
now.getDate(), | ||
now.getHours(), | ||
now.getMinutes(), | ||
now.getSeconds() | ||
]; | ||
time_string = time_components.join('-'); | ||
} | ||
@@ -57,7 +65,22 @@ | ||
var install_location = dir.path; | ||
var zip_path = install_location + '/' + archive_name + '.zip'; | ||
npm.commands.install(install_location, options.package_folder, function () { | ||
var output = fs.createWriteStream(install_location + '/' + archive_name + '.zip'); | ||
var output = fs.createWriteStream(zip_path); | ||
var zipArchive = archive('zip'); | ||
/* | ||
* Monkey patch to ensure permissions are always 777 | ||
* Prevents issues on Windows for directories that don't have execute permissions | ||
* See https://github.com/Tim-B/grunt-aws-lambda/issues/6 | ||
*/ | ||
var old_normalizeEntryData = zipArchive._normalizeEntryData; | ||
zipArchive._normalizeEntryData = function(data, stats) { | ||
// 0777 file permission | ||
// data.mode = 511; | ||
return old_normalizeEntryData.apply(zipArchive, [data, stats]); | ||
}; | ||
zipArchive.pipe(output); | ||
@@ -68,2 +91,3 @@ | ||
src: ['./**'], | ||
dot:true, | ||
expand: true, | ||
@@ -78,13 +102,12 @@ cwd: install_location + '/node_modules/' + pkg.name | ||
mkdirp('./' + options.dist_folder, function (err) { | ||
fs.createReadStream(install_location + '/' + archive_name + '.zip').pipe( | ||
fs.createWriteStream('./' + options.dist_folder + '/' + archive_name + '.zip') | ||
); | ||
var dist_path = './' + options.dist_folder + '/' + archive_name + '.zip'; | ||
var dist_zip = fs.createWriteStream(dist_path); | ||
fs.createReadStream(zip_path).pipe(dist_zip); | ||
rimraf(install_location, function () { | ||
grunt.config.set('lambda_deploy.' + task.target + '.package', | ||
'./' + options.dist_folder + '/' + archive_name + '.zip'); | ||
grunt.log.writeln('Created package at ' + options.dist_folder + '/' + archive_name + '.zip'); | ||
done(true); | ||
dist_zip.on('close', function () { | ||
rimraf(install_location, function () { | ||
grunt.config.set('lambda_deploy.' + task.target + '.package', dist_path); | ||
grunt.log.writeln('Created package at ' + dist_path); | ||
done(true); | ||
}); | ||
}); | ||
@@ -91,0 +114,0 @@ }); |
@@ -37,3 +37,3 @@ 'use strict'; | ||
default_options: function (test) { | ||
test.expect(4); | ||
test.expect(5); | ||
glob("my-lambda-function_0-0-1_*.zip", {cwd: 'tmp/dist'}, function (er, files) { | ||
@@ -45,7 +45,8 @@ test.equals(1, files.length); | ||
test.equals(2, zipEntries.length); | ||
test.equals(3, zipEntries.length); | ||
var required = [ | ||
'index.js', | ||
'package.json' | ||
'package.json', | ||
'.test' | ||
]; | ||
@@ -52,0 +53,0 @@ |
Sorry, the diff of this file is not supported yet
491
485
34745
25