Comments (4)
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.
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.shThe 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 ..
gulpAnd 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.
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gulp-awslambda.