-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathgulpfile.js
55 lines (45 loc) · 1.22 KB
/
gulpfile.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
54
55
'use strict';
require('dotenv').config();
var gulp = require('gulp');
var zip = require('gulp-zip');
var del = require('del');
var install = require('gulp-install');
var runSequence = require('run-sequence');
var awsLambda = require('node-aws-lambda');
var pkg = require('./package.json');
var packageFile = pkg.name + '_' + pkg.version + '_' + '.zip';
gulp.task('clean', function () {
return del(['./dist', './build']);
});
gulp.task('js', function () {
return gulp.src('./src/index.js')
.pipe(gulp.dest('build/'));
});
gulp.task('env', function () {
return gulp.src('.env')
.pipe(gulp.dest('build/'));
});
gulp.task('node-mods', function () {
return gulp.src('./package.json')
.pipe(gulp.dest('build/'))
.pipe(install({production: true}));
});
gulp.task('zip', function () {
return gulp.src(['build/**/*', '!build/package.json'], {
dot: true
})
.pipe(zip(packageFile))
.pipe(gulp.dest('./dist/'));
});
gulp.task('upload', function (callback) {
awsLambda.deploy('./dist/' + packageFile, require('./lambda-config.js'), callback);
});
gulp.task('deploy', function (callback) {
return runSequence(
['clean'],
['js', 'env', 'node-mods'],
['zip'],
['upload'],
callback
);
});