From 233ae3337fbe7574fd042a1d7fd6994916479a49 Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Fri, 30 Aug 2024 19:06:04 +0800 Subject: [PATCH] fix(cli): incorrect exec context --- cli/src/run.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cli/src/run.ts b/cli/src/run.ts index 3c153672..f9ebfa01 100644 --- a/cli/src/run.ts +++ b/cli/src/run.ts @@ -1,3 +1,5 @@ +import process from 'node:process' +import path from 'node:path' import { intro, outro, spinner } from '@clack/prompts' import { execaCommand } from 'execa' import colors from 'picocolors' @@ -19,16 +21,17 @@ export async function run(mode: Mode, root?: string) { await generate(mode, data) + const cwd = path.join(process.cwd(), data.root) if (data.git) { progress.message(t('spinner.git')) - await execaCommand('git init') + await execaCommand('git init', { cwd }) } const pm = data.packageManager if (data.install) { progress.message(t('spinner.install')) - await execaCommand(pm === 'yarn' ? 'yarn' : `${pm} install`) + await execaCommand(pm === 'yarn' ? 'yarn' : `${pm} install`, { cwd }) } const cdCommand = mode === Mode.create ? colors.green(`cd ${data.root}`) : ''