Tim-B / grunt-aws-lambda

A grunt plugin to assist in developing functions for AWS Lambda.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Task lambda_package create empty zip

jeromeheissler opened this issue · comments

I try to run the task on my iMac the generated zip doesn't contain any sources.

I added this piece of code to see files that are added to the archive. And I see nothing.

zipArchive.on('entry', function(data)   {
  console.log(data);
 });

Next I change the install_location to a directory on the project root, all the files to be compressed are listed correctly. But the archive is corrupt.

var install_location = "./.tmp";

Finally I changed the script that copies the archive to wait for the copy before deleting, and everything works.

output.on('close', function () {
  mkdirp('./' + options.dist_folder, function (err) {
    fs.createReadStream(install_location + '/' + archive_name + '.zip').pipe(
      fs.createWriteStream('./' + options.dist_folder + '/' + archive_name + '.zip')
    ).on('close', function(){
      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);
      });
    });
  });
});

I'm a beginner with node js and grunt, there is there a problem in my configuration or worries with the task ?

commented

Hi @jeromeheissler

Is it at all possible to post a link to your code so I can try and run it myself? Even if just an example that prints "Hello World" or something but still exhibits the issue?

Also, it might be useful to try a basic example using the archiver package to see if the NPM package itself is the issue or just this implementation using it.

https://www.npmjs.com/package/archiver

Cheers, Tim.

I create a project on github with a Hello World. When I run the command grunt lambda_package I have the same problem.

https://github.com/jeromeheissler/test-lamdba

I will try to use the archiver package alone

I also tried to clone your project and run the tests. I have this error:

> grunt test
Running "clean:tests" (clean) task

Running "lambda_package:default_options" (lambda_package) task
Created package at tmp/dist/my-lambda-function_0-0-1_2015-0-29-11-55-59.zip

Running "lambda_package:custom_options" (lambda_package) task
Created package at tmp/dist/another-lambda-function_0-0-1_latest.zip

Running "nodeunit:tests" (nodeunit) task
Testing lambda_invoke_test.js..OK
Testing lambda_package_test.jsFatal error: Invalid or unsupported zip format. No END header found

Hi, same problem, empty deploy package...

commented

Hi @teu would it be possible to try a hello world example using the archiver package? https://www.npmjs.com/package/archiver

That will help narrow down if the issue is with the library which generates the zip or how it's been implemented here.

Hi,

had same problem with local file and buffer on ubuntu (also on AWS Lambda) so switched to another library. time permitting will try to submit something.

commented

I bumped the adm-zip version to the latest one which I hope will resolve this issue. I also tested it in a Windows 7 VM and it all worked fine.

commented

I've just released a new version including the pull request from @qen so hopefully this will be fixed. Let me know how you go.