-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
53 lines (46 loc) · 1.57 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
var gulp = require('gulp'),
zip = require('gulp-zip'),
del = require('del'),
install = require('gulp-install'),
awsLambda = require('node-aws-lambda'),
envify = require('gulp-envify'),
_ = require('lodash'),
path = require('path');
module.exports = function(gulp) {
gulp.task('clean', function(cb) {
return del(['./dist', './dist.zip'], cb);
});
gulp.task('js', function() {
return gulp.src(['src/**/*', '!src/**/*.spec.js'])
.pipe(envify(process.env))
.pipe(gulp.dest('dist/'));
});
gulp.task('node-mods', function() {
return gulp.src('./package.json')
.pipe(gulp.dest('dist/'))
.pipe(install({
production: true
}));
});
gulp.task('zip', function() {
return gulp.src(['dist/**/*', '!dist/package.json'])
.pipe(zip('dist.zip'))
.pipe(gulp.dest('./'));
});
gulp.task('upload', function(callback) {
var packageDefinition = require(path.join(process.cwd(), './package.json'))
var lambdaConfig = packageDefinition.lambda;
// set defaults
_.defaultsDeep(lambdaConfig, {
region: 'us-east-1',
handler: 'index.handler',
description: "",
role: 'arn:aws:iam::' + process.env.AWS_ACCOUNT_ID + ':role/' + (packageDefinition.lambda.roleName || 'aws-lambda-default'),
timeout: 180,
memorySize: 512
});
awsLambda.deploy(
'./dist.zip', lambdaConfig,
callback);
});
};