From f05ada6cd26da2d5e447aec46912ca626c91f32c Mon Sep 17 00:00:00 2001 From: Alina Sireneva Date: Thu, 22 Feb 2024 14:20:23 +0300 Subject: [PATCH] fix(create-bot): use `cross-spawn` i hate windows lol --- packages/create-bot/package.json | 8 +++++--- packages/create-bot/src/utils.ts | 6 ++++-- pnpm-lock.yaml | 16 ++++++++++++++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/packages/create-bot/package.json b/packages/create-bot/package.json index d559c8e7..84d2fd2c 100644 --- a/packages/create-bot/package.json +++ b/packages/create-bot/package.json @@ -14,13 +14,15 @@ "create-bot": "./src/main.js" }, "dependencies": { - "chalk": "^5.3.0", + "chalk": "5.3.0", + "cross-spawn": "7.0.3", "glob": "10.2.6", - "handlebars": "^4.7.8", + "handlebars": "4.7.8", "inquirer": "9.2.11", "open": "9.1.0" }, "devDependencies": { - "@types/inquirer": "^9.0.6" + "@types/inquirer": "^9.0.6", + "@types/cross-spawn": "^6.0.6" } } diff --git a/packages/create-bot/src/utils.ts b/packages/create-bot/src/utils.ts index f808f4a6..9bb27ada 100644 --- a/packages/create-bot/src/utils.ts +++ b/packages/create-bot/src/utils.ts @@ -1,15 +1,17 @@ import chalk from 'chalk' -import * as cp from 'child_process' +import { spawn } from 'cross-spawn' export function exec(cwd: string, ...cmd: string[]) { return new Promise((resolve, reject) => { 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', cwd, }) + proc.on('error', reject) + proc.on('close', (code) => { if (code === 0) { resolve() diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 44cf6bcd..40b17505 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -152,13 +152,16 @@ importers: packages/create-bot: dependencies: chalk: - specifier: ^5.3.0 + specifier: 5.3.0 version: 5.3.0 + cross-spawn: + specifier: 7.0.3 + version: 7.0.3 glob: specifier: 10.2.6 version: 10.2.6 handlebars: - specifier: ^4.7.8 + specifier: 4.7.8 version: 4.7.8 inquirer: specifier: 9.2.11 @@ -167,6 +170,9 @@ importers: specifier: 9.1.0 version: 9.1.0 devDependencies: + '@types/cross-spawn': + specifier: ^6.0.6 + version: 6.0.6 '@types/inquirer': specifier: ^9.0.6 version: 9.0.6 @@ -1254,6 +1260,12 @@ packages: /@types/chai@4.3.5: 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: resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==}