fix(create-bot): use cross-spawn

i hate windows lol
This commit is contained in:
alina 🌸 2024-02-22 14:20:23 +03:00
parent 8c38f836dd
commit f05ada6cd2
Signed by: teidesu
SSH key fingerprint: SHA256:uNeCpw6aTSU4aIObXLvHfLkDa82HWH9EiOj9AXOIRpI
3 changed files with 23 additions and 7 deletions

View file

@ -14,13 +14,15 @@
"create-bot": "./src/main.js" "create-bot": "./src/main.js"
}, },
"dependencies": { "dependencies": {
"chalk": "^5.3.0", "chalk": "5.3.0",
"cross-spawn": "7.0.3",
"glob": "10.2.6", "glob": "10.2.6",
"handlebars": "^4.7.8", "handlebars": "4.7.8",
"inquirer": "9.2.11", "inquirer": "9.2.11",
"open": "9.1.0" "open": "9.1.0"
}, },
"devDependencies": { "devDependencies": {
"@types/inquirer": "^9.0.6" "@types/inquirer": "^9.0.6",
"@types/cross-spawn": "^6.0.6"
} }
} }

View file

@ -1,15 +1,17 @@
import chalk from 'chalk' import chalk from 'chalk'
import * as cp from 'child_process' import { spawn } from 'cross-spawn'
export function exec(cwd: string, ...cmd: string[]) { export function exec(cwd: string, ...cmd: string[]) {
return new Promise<void>((resolve, reject) => { return new Promise<void>((resolve, reject) => {
console.log(`${chalk.blue('$')} ${cmd.join(' ')}`) console.log(`${chalk.blue('$')} ${cmd.join(' ')}`)
const proc = cp.spawn(cmd[0], cmd.slice(1), { const proc = spawn(cmd[0], cmd.slice(1), {
stdio: 'inherit', stdio: 'inherit',
cwd, cwd,
}) })
proc.on('error', reject)
proc.on('close', (code) => { proc.on('close', (code) => {
if (code === 0) { if (code === 0) {
resolve() resolve()

View file

@ -152,13 +152,16 @@ importers:
packages/create-bot: packages/create-bot:
dependencies: dependencies:
chalk: chalk:
specifier: ^5.3.0 specifier: 5.3.0
version: 5.3.0 version: 5.3.0
cross-spawn:
specifier: 7.0.3
version: 7.0.3
glob: glob:
specifier: 10.2.6 specifier: 10.2.6
version: 10.2.6 version: 10.2.6
handlebars: handlebars:
specifier: ^4.7.8 specifier: 4.7.8
version: 4.7.8 version: 4.7.8
inquirer: inquirer:
specifier: 9.2.11 specifier: 9.2.11
@ -167,6 +170,9 @@ importers:
specifier: 9.1.0 specifier: 9.1.0
version: 9.1.0 version: 9.1.0
devDependencies: devDependencies:
'@types/cross-spawn':
specifier: ^6.0.6
version: 6.0.6
'@types/inquirer': '@types/inquirer':
specifier: ^9.0.6 specifier: ^9.0.6
version: 9.0.6 version: 9.0.6
@ -1254,6 +1260,12 @@ packages:
/@types/chai@4.3.5: /@types/chai@4.3.5:
resolution: {integrity: sha512-mEo1sAde+UCE6b2hxn332f1g1E8WfYRu6p5SvTKr2ZKC1f7gFJXk4h5PyGP9Dt6gCaG8y8XhwnXWC6Iy2cmBng==} resolution: {integrity: sha512-mEo1sAde+UCE6b2hxn332f1g1E8WfYRu6p5SvTKr2ZKC1f7gFJXk4h5PyGP9Dt6gCaG8y8XhwnXWC6Iy2cmBng==}
/@types/cross-spawn@6.0.6:
resolution: {integrity: sha512-fXRhhUkG4H3TQk5dBhQ7m/JDdSNHKwR2BBia62lhwEIq9xGiQKLxd6LymNhn47SjXhsUEPmxi+PKw2OkW4LLjA==}
dependencies:
'@types/node': 20.10.0
dev: true
/@types/estree@1.0.5: /@types/estree@1.0.5:
resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==}