Skip to content

Commit f1008b7

Browse files
fix: git detection inside preconditions failed (#394)
* don't use `tinyexec` for git detection * changeset * Update packages/cli/commands/add/preconditions.ts Co-authored-by: Conduitry <git@chor.date> --------- Co-authored-by: Conduitry <git@chor.date>
1 parent cf5fb16 commit f1008b7

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

.changeset/friendly-lemons-shop.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'sv': patch
3+
---
4+
5+
fix: git detection inside preconditions failed

packages/cli/commands/add/preconditions.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { exec } from 'tinyexec';
1+
import { exec } from 'node:child_process';
2+
import { promisify } from 'node:util';
23
import type { AddonSetupResult, AddonWithoutExplicitArgs, Precondition } from '@sveltejs/cli-core';
34
import { UnsupportedError } from '../../utils/errors.ts';
45

@@ -21,9 +22,9 @@ export function getGlobalPreconditions(
2122
// there are no pending changes. If the below command is run outside of a git repository,
2223
// git will exit with a failing exit code, which will trigger the catch statement.
2324
// also see https://remarkablemark.org/blog/2017/10/12/check-git-dirty/#git-status
24-
const { stdout } = await exec('git', ['status', '--short'], {
25-
nodeOptions: { cwd },
26-
throwOnError: true
25+
const asyncExec = promisify(exec);
26+
const { stdout } = await asyncExec('git status --short', {
27+
cwd
2728
});
2829

2930
if (stdout) {

0 commit comments

Comments
 (0)