-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
collect-assets.js
40 lines (33 loc) · 979 Bytes
/
collect-assets.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
const { promisify } = require('util')
const { exec } = require('child_process')
const os = require('os')
const path = require('path')
const execPromise = promisify(exec)
const isCI = !!process.env.VERCEL_ENV
if (!isCI) {
console.log('not in a vercel CI environment, exiting...')
return
}
async function run() {
try {
const nitricPath = path.join(os.homedir(), '.nitric', 'bin', 'nitric')
// Array of commands to execute
const commands = [
'curl -L https://nitric.io/install?version=latest | bash',
`mv ${nitricPath} /usr/local/bin/`,
'nitric version',
'nitric help > src/assets/cli-usage.txt',
]
// Run each command in the array
for (const command of commands) {
const { stdout, stderr } = await execPromise(command)
console.log(`Command output: ${stdout}`)
if (stderr) {
console.error(`Command stderr: ${stderr}`)
}
}
} catch (error) {
console.log(error.message)
}
}
run()