fix
This commit is contained in:
@@ -85,7 +85,7 @@ The default deploy flow is:
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
git pull --ff-only
|
git pull --ff-only
|
||||||
npm install
|
npm install --include=dev
|
||||||
npm run build
|
npm run build
|
||||||
pm2 reload tssbot-web --update-env
|
pm2 reload tssbot-web --update-env
|
||||||
```
|
```
|
||||||
|
|||||||
+24
-5
@@ -66,18 +66,33 @@ function verifySignature(rawBody, signature) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function run(command, args) {
|
function commandFor(command) {
|
||||||
|
if (process.platform !== 'win32') return command
|
||||||
|
if (command === 'npm') return 'npm.cmd'
|
||||||
|
if (command === 'pm2') return 'pm2.cmd'
|
||||||
|
return command
|
||||||
|
}
|
||||||
|
|
||||||
|
function run(command, args, options = {}) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const child = spawn(command, args, {
|
const label = [command, ...args].join(' ')
|
||||||
|
console.log(`deploy step started: ${label}`)
|
||||||
|
|
||||||
|
const child = spawn(commandFor(command), args, {
|
||||||
cwd: __dirname,
|
cwd: __dirname,
|
||||||
|
env: { ...process.env, ...options.env },
|
||||||
shell: process.platform === 'win32',
|
shell: process.platform === 'win32',
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
})
|
})
|
||||||
|
|
||||||
child.on('error', reject)
|
child.on('error', reject)
|
||||||
child.on('exit', (code) => {
|
child.on('exit', (code) => {
|
||||||
if (code === 0) resolve()
|
if (code === 0) {
|
||||||
else reject(new Error(`${command} ${args.join(' ')} exited with ${code}`))
|
console.log(`deploy step completed: ${label}`)
|
||||||
|
resolve()
|
||||||
|
} else {
|
||||||
|
reject(new Error(`${label} exited with ${code}`))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -147,7 +162,11 @@ function notifyDiscordRestart() {
|
|||||||
|
|
||||||
async function deploy() {
|
async function deploy() {
|
||||||
await run('git', ['pull', '--ff-only'])
|
await run('git', ['pull', '--ff-only'])
|
||||||
await run('npm', ['install'])
|
await run('npm', ['install', '--include=dev'], {
|
||||||
|
env: {
|
||||||
|
npm_config_production: 'false',
|
||||||
|
},
|
||||||
|
})
|
||||||
await run('npm', ['run', 'build'])
|
await run('npm', ['run', 'build'])
|
||||||
|
|
||||||
for (const target of RESTART_TARGETS) {
|
for (const target of RESTART_TARGETS) {
|
||||||
|
|||||||
Reference in New Issue
Block a user