-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.js
More file actions
58 lines (48 loc) · 1.56 KB
/
deploy.js
File metadata and controls
58 lines (48 loc) · 1.56 KB
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
56
57
58
// const git = require("simple-git")
const npmRunScript = require('npm-run-script')
const run = () => {
console.log(__dirname)
// const repo = git(__dirname)
// const gitPull = (thisRepo = repo) => {
// return new Promise((resolve) => {
// thisRepo.pull(function () {
// resolve()
// })
// })
// }
const runScript = (script, name) => {
console.log(name + ' - start')
return new Promise((resolve, reject) => {
const child = npmRunScript(
script,
{
stdio: 'ignore' // quiet
}
);
child.once('error', (error) => {
process.exit(1);
reject(error);
});
child.once('exit', (exitCode) => {
console.log(name + ' - complete')
// process.exit(exitCode);
resolve();
});
})
}
// gitPull().then(() => {
// console.log('[GIT] pull - complete')
// return true
// })
// .then(() => runScript('npm install', '[NPM] install'))
runScript('npm install', '[NPM] install')
// .then(() => runScript('npm run build', '[NPM] build'))
// .then(() => runScript('pm2 delete sp-boilerplate', '[PM2] kill service'))
.then(() => runScript('npm run start:pm2', '[NPM] build & [PM2] starting server'))
.then(() => {
console.log('ALL DONE!')
npmRunScript('pm2 list')
return true
})
}
run()