Giter Site home page Giter Site logo

Comments (4)

willyg302 avatar willyg302 commented on July 30, 2024

I tried using gulp-install but quickly gave up because it seems to install the Node modules in place and doesn't forward them down the stream, which means they won't be included in the zip. My solution was the following:

Assume a package structure like this:

src/
    index.js
    package.json
Gulpfile.js
package.json
publish.sh

The src/ directory contains your actual Lambda function package, including any dependencies needed (async, Mocha, etc.). Then there's the "outer" directory which contains the build logic. I whipped up a quick shell script -- publish.sh -- to do what I thought gulp-install would do:

rm -rf dest
cp -R src dest
cd dest && npm install --production && cd ..
gulp

And then in the Gulpfile:

gulp.task('default', function() {
    return gulp.src('dest/**/*')
        .pipe(zip('archive.zip'))
        .pipe(lambda(lambda_params, opts))
        .pipe(gulp.dest('.'));
});

Not entirely pretty, but it works. Let me know if that helps!

from gulp-awslambda.

matthewchung74 avatar matthewchung74 commented on July 30, 2024

Thanks for responding Willy. In this case, if Mocha is in src/ , wouldn't
that get copied up to AWS as well?

On Thu, Jul 30, 2015 at 9:48 PM, WillyG Productions <
[email protected]> wrote:

I tried using gulp-install but quickly gave up because it seems to install
the Node modules in place and doesn't forward them down the stream, which
means they won't be included in the zip. My solution was the following:

Assume a package structure like this:

src/
index.js
package.json
Gulpfile.js
package.json
publish.sh

The src/ directory contains your actual Lambda function package,
including any dependencies needed (async, Mocha, etc.). Then there's the
"outer" directory which contains the build logic. I whipped up a quick
shell script -- publish.sh -- to do what I thought gulp-install would
do:

rm -rf dest
cp -R src destcd dest && npm install --production && cd ..
gulp

And then in the Gulpfile:

gulp.task('default', function() {
return gulp.src('dest/*/')
.pipe(zip('archive.zip'))
.pipe(lambda(lambda_params, opts))
.pipe(gulp.dest('.'));
});

Not entirely pretty, but it works. Let me know if that helps!


Reply to this email directly or view it on GitHub
#2 (comment)
.

Regards,
Matt

from gulp-awslambda.

willyg302 avatar willyg302 commented on July 30, 2024

Oh you're right, sorry about that. The goal is to copy over to dest but exclude node_modules, which means that this command (instead of cp) should do the trick:

rsync -r src dest --exclude node_modules

from gulp-awslambda.

matthewchung74 avatar matthewchung74 commented on July 30, 2024

Thank you.

On Friday, July 31, 2015, WillyG Productions [email protected]
wrote:

Oh you're right, sorry about that. The goal is to copy over to dest but
exclude node_modules, which means that this command (instead of cp)
should do the trick:

rsync -r src dest --exclude node_modules


Reply to this email directly or view it on GitHub
#2 (comment)
.

Regards,
Matt

from gulp-awslambda.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.