Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: git detection inside preconditions failed #394

Merged
merged 3 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 statzs --short', {
cwd
manuel3108 marked this conversation as resolved.
Show resolved Hide resolved
});

if (stdout) {
Expand Down
Loading