Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 42b2c8f

Browse files
author
Parth Shah
committed
reading cofnig from package.json
1 parent c57950f commit 42b2c8f

File tree

2 files changed

+55
-34
lines changed

2 files changed

+55
-34
lines changed

index.js

+51-31
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,57 @@
11
var gulp = require('gulp'),
2-
zip = require('gulp-zip'),
3-
del = require('del'),
4-
install = require('gulp-install'),
5-
awsLambda = require('node-aws-lambda'),
6-
envify = require('gulp-envify'),
7-
path = require('path');
2+
zip = require('gulp-zip'),
3+
del = require('del'),
4+
install = require('gulp-install'),
5+
awsLambda = require('node-aws-lambda'),
6+
envify = require('gulp-envify'),
7+
_ = require('lodash'),
8+
path = require('path');
89

910
module.exports = function(gulp) {
1011

11-
gulp.task('clean', function(cb) {
12-
return del(['./dist', './dist.zip'], cb);
13-
});
14-
15-
gulp.task('js', function() {
16-
return gulp.src(['src/**/*', '!src/**/*.spec.js'])
17-
.pipe(envify(process.env))
18-
.pipe(gulp.dest('dist/'));
19-
});
20-
21-
gulp.task('node-mods', function() {
22-
return gulp.src('./package.json')
23-
.pipe(gulp.dest('dist/'))
24-
.pipe(install({ production: true }));
25-
});
26-
27-
gulp.task('zip', function() {
28-
return gulp.src(['dist/**/*', '!dist/package.json'])
29-
.pipe(zip('dist.zip'))
30-
.pipe(gulp.dest('./'));
31-
});
32-
33-
gulp.task('upload', function(callback) {
34-
awsLambda.deploy('./dist.zip', require(path.join(process.cwd(), "lambda-config.js")), callback);
35-
});
12+
gulp.task('clean', function(cb) {
13+
return del(['./dist', './dist.zip'], cb);
14+
});
15+
16+
gulp.task('js', function() {
17+
return gulp.src(['src/**/*', '!src/**/*.spec.js'])
18+
.pipe(envify(process.env))
19+
.pipe(gulp.dest('dist/'));
20+
});
21+
22+
gulp.task('node-mods', function() {
23+
return gulp.src('./package.json')
24+
.pipe(gulp.dest('dist/'))
25+
.pipe(install({
26+
production: true
27+
}));
28+
});
29+
30+
gulp.task('zip', function() {
31+
return gulp.src(['dist/**/*', '!dist/package.json'])
32+
.pipe(zip('dist.zip'))
33+
.pipe(gulp.dest('./'));
34+
});
35+
36+
gulp.task('upload', function(callback) {
37+
var packageDefinition = require(path.join(process.cwd(), './package.json'))
38+
39+
var lambdaConfig = packageDefinition.lambda;
40+
// set defaults
41+
_.defaultsDeep(lambdaConfig, {
42+
region: 'us-east-1',
43+
handler: 'index.handler',
44+
description: "",
45+
role: 'arn:aws:iam::' + process.env.AWS_ACCOUNT_ID + ':role/' + (packageDefinition.lambda.role || 'aws-lambda-default'),
46+
timeout: 180,
47+
memorySize: 512
48+
});
49+
50+
awsLambda.deploy(
51+
'./dist.zip', lambdaConfig,
52+
callback);
53+
});
54+
55+
3656

3757
};

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tc-lambda-gulp-tasks",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "Topcoder Gulp tasks to deploy AWS lambdas",
55
"main": "index.js",
66
"repository": {
@@ -20,9 +20,10 @@
2020
"aws-sdk": "^2.1.45",
2121
"del": "^2.0.0",
2222
"gulp": "^3.9.0",
23-
"gulp-install": "^0.5.0",
2423
"gulp-envify": "^1.0.0",
24+
"gulp-install": "^0.5.0",
2525
"gulp-zip": "^3.0.2",
26-
"node-aws-lambda": "^0.1.5"
26+
"lodash": "^4.11.1",
27+
"node-aws-lambda": "^0.1.8"
2728
}
2829
}

0 commit comments

Comments
 (0)