Skip to content

Commit

Permalink
fix: git detection inside preconditions failed (#394)
Browse files Browse the repository at this point in the history
* don't use `tinyexec` for git detection

* changeset

* Update packages/cli/commands/add/preconditions.ts

Co-authored-by: Conduitry <[email protected]>

---------

Co-authored-by: Conduitry <[email protected]>
  • Loading branch information
manuel3108 and Conduitry authored Jan 16, 2025
1 parent cf5fb16 commit f1008b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/friendly-lemons-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'sv': patch
---

fix: git detection inside preconditions failed
9 changes: 5 additions & 4 deletions packages/cli/commands/add/preconditions.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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) {
Expand Down

0 comments on commit f1008b7

Please sign in to comment.