8000 fix working directory bug · svelte-add/svelte-add@26a993a · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Oct 20, 2024. It is now read-only.

Commit 26a993a

Browse files
committed
fix working directory bug
1 parent ce4ea7e commit 26a993a

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

packages/core/adder/execute.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ async function executePlan<Args extends OptionDefinition>(
129129

130130
// preconditions
131131
if (!executionPlan.commonCliOptions.skipPreconditions)
132-
await validatePreconditions(adderDetails, executingAdder.name, isTesting);
132+
await validatePreconditions(adderDetails, executingAdder.name, executionPlan.workingDirectory, isTesting);
133133

134134
// ask the user questions about unselected options
135135
await requestMissingOptionsFromUser(adderDetails, executionPlan);

packages/core/adder/preconditions.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import pc from "picocolors";
55
import { Precondition } from "./config.js";
66
import { executeCli } from "../utils/common.js";
77

8-
function getGlobalPreconditions(executingCli: string): { name: string; preconditions: Precondition[] | undefined } {
8+
function getGlobalPreconditions(
9+
executingCli: string,
10+
workingDirectory: string,
11+
): { name: string; preconditions: Precondition[] | undefined } {
912
return {
1013
name: executingCli,
1114
preconditions: [
@@ -21,7 +24,7 @@ function getGlobalPreconditions(executingCli: string): { name: string; precondit
2124
// there are no pending changes. If the below command is run outside of a git repository,
2225
// git will exit with a failing exit code, which will trigger the catch statement.
2326
// also see https://remarkablemark.org/blog/2017/10/12/check-git-dirty/#git-status
24-
await executeCli("git", ["status", "--short"], process.cwd(), {
27+
await executeCli("git", ["status", "--short"], workingDirectory, {
2528
onData: (data, program, resolve) => {
2629
outputText += data;
2730
},
@@ -44,6 +47,7 @@ function getGlobalPreconditions(executingCli: string): { name: string; precondit
4447
export async function validatePreconditions<Args extends OptionDefinition>(
4548
adderDetails: AdderDetails<Args>[],
4649
executingCliName: string,
50+
workingDirectory: string,
4751
isTesting: boolean,
4852
) {
4953
const multipleAdders = adderDetails.length > 1;
@@ -56,7 +60,7 @@ export async function validatePreconditions<Args extends OptionDefinition>(
5660
preconditions: checks.preconditions,
5761
};
5862
});
59-
const combinedPreconditions = [getGlobalPreconditions(executingCliName), ...adderPreconditions];
63+
const combinedPreconditions = [getGlobalPreconditions(executingCliName, workingDirectory), ...adderPreconditions];
6064

6165
for (const { name, preconditions } of combinedPreconditions) {
6266
if (!preconditions) continue;

0 commit comments

Comments
 (0)
0