diff --git a/.changeset/friendly-lemons-shop.md b/.changeset/friendly-lemons-shop.md new file mode 100644 index 00000000..90e1d65b --- /dev/null +++ b/.changeset/friendly-lemons-shop.md @@ -0,0 +1,5 @@ +--- +'sv': patch +--- + +fix: git detection inside preconditions failed diff --git a/packages/cli/commands/add/preconditions.ts b/packages/cli/commands/add/preconditions.ts index c8a90f93..99da6c52 100644 --- a/packages/cli/commands/add/preconditions.ts +++ b/packages/cli/commands/add/preconditions.ts @@ -1,4 +1,5 @@ -import { exec } from 'tinyexec'; +import { exec } from 'node:child_process'; +import { promisify } from 'node:util'; import type { AddonSetupResult, AddonWithoutExplicitArgs, Precondition } from '@sveltejs/cli-core'; import { UnsupportedError } from '../../utils/errors.ts'; @@ -21,9 +22,9 @@ export function getGlobalPreconditions( // there are no pending changes. If the below command is run outside of a git repository, // git will exit with a failing exit code, which will trigger the catch statement. // also see https://remarkablemark.org/blog/2017/10/12/check-git-dirty/#git-status - const { stdout } = await exec('git', ['status', '--short'], { - nodeOptions: { cwd }, - throwOnError: true + const asyncExec = promisify(exec); + const { stdout } = await asyncExec('git status --short', { + cwd }); if (stdout) {