forked from Affirmatech/MeshSense
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.mjs
executable file
·28 lines (22 loc) · 958 Bytes
/
update.mjs
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
#!/usr/bin/env node
import { spawn } from 'child_process'
import { styleText } from 'util';
let runCmd = (commandString) => new Promise((resolve, reject) => {
let cmd = spawn(commandString, { shell: true, env: process.env })
cmd.stdout.on('data', (data) => process.stdout.write(data))
cmd.stderr.on('data', (data) => process.stderr.write(data))
cmd.on('error', (e) => reject(e))
cmd.on('close', (e) => e == 0 ? resolve() : reject(`Return code: ${e}`))
})
let platform = process.platform.replace(/32$/, '').replace('darwin', 'mac')
console.log(styleText(['magenta', 'bold'], 'Updating Project'))
await runCmd('git pull')
console.log(styleText(['magenta', 'bold'], 'Updating UI'))
process.chdir('ui')
await runCmd('npm i')
console.log(styleText(['magenta', 'bold'], 'Updating API'))
process.chdir('../api')
await runCmd('npm i')
console.log(styleText(['magenta', 'bold'], 'Updating Electron'))
process.chdir('../electron')
await runCmd(`npm i`)