-
Notifications
You must be signed in to change notification settings - Fork 14
/
dpl.js
27 lines (26 loc) · 1023 Bytes
/
dpl.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
#!/usr/bin/env node
const start = Date.now();
require('./test/00_env.test.js'); // check if AWS keys are set
const dpl = require('./lib/index.js');
const pkg = require(dpl.utils.getBasepath() + 'package.json');
dpl.copyfiles(); // copy required files & dirs
if (pkg.files_to_deploy.indexOf('.env') > -1) {
dpl.utils.makeEnvFile();
}
dpl.install_node_modules(); // install only production node_modules
dpl.zip(); // zip the /dist directory
dpl.upload(function (err, data) { // upload the .zip file to AWS:
let exitcode = 0;
if (err) {
console.log('- - - - - - - - - - - - - - - - - - - - - - - DEPLOY ERROR');
console.log(err);
console.log('- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -');
exitcode = 1;
} else {
console.log('- - - - - - - - > Lambda Function Deployed:');
console.log(data);
console.log('- - - - - - - - > took', (Date.now() - start) / 1000, 'seconds');
}
dpl.utils.cleanUp(); // delete /dist and .zip file for next time
process.exit(exitcode);
});