Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 71aeca4

Browse files
committed
Remove remaining execSync calls
1 parent 96b18f5 commit 71aeca4

5 files changed

Lines changed: 18 additions & 21 deletions

File tree

.changeset/tidy-actors-worry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"ultracite": patch
3+
---
4+
5+
Remove remaining execSync calls

packages/cli/__tests__/initialize.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -866,10 +866,10 @@ describe("initialize", () => {
866866

867867
expect(mockSelect).not.toHaveBeenCalled();
868868
expect(mockSpawn).toHaveBeenCalledWith(
869-
"npx skills add haydenbleasel/ultracite",
870-
[],
869+
"npx",
870+
["skills", "add", "haydenbleasel/ultracite"],
871871
expect.objectContaining({
872-
shell: true,
872+
shell: false,
873873
stdio: "pipe",
874874
})
875875
);

packages/cli/src/integrations/husky.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { execSync } from "node:child_process";
21
import { mkdir, readFile, writeFile } from "node:fs/promises";
32

43
import { addDevDependency, dlxCommand } from "nypm";
54
import type { PackageManager, PackageManagerName } from "nypm";
65

6+
import { runCommandSync } from "../run-command";
77
import { exists, isMonorepo, updatePackageJson } from "../utils";
88

99
const createLintStagedHookScript = (lintStagedCommand: string) => `#!/bin/sh
@@ -68,13 +68,13 @@ export const husky = {
6868
exists: () => exists(path),
6969
init: (packageManager: PackageManagerName) => {
7070
// Initialize husky - this sets up git hooks infrastructure
71-
const initCommand = dlxCommand(packageManager, "husky", {
71+
const [command, ...args] = dlxCommand(packageManager, "husky", {
7272
args: ["init"],
73-
});
73+
}).split(" ");
74+
75+
const result = runCommandSync(command, args, { stdio: "pipe" });
7476

75-
try {
76-
execSync(initCommand, { stdio: "pipe" });
77-
} catch {
77+
if (result.error || (result.status !== null && result.status !== 0)) {
7878
// If init fails, it might be because it's already initialized
7979
// Continue anyway as we'll create the hook file next
8080
}

packages/cli/src/run-command.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,6 @@ export const runCommandSync = (
2424
shell: false,
2525
});
2626

27-
export const runCommandShellSync = (
28-
command: string,
29-
options: RunCommandOptions
30-
): RunCommandResult =>
31-
crossSpawnSync(command, [], {
32-
...options,
33-
shell: true,
34-
});
35-
3627
export const exitOnCommandFailure = (
3728
commandName: string,
3829
result: RunCommandResult

packages/cli/src/skill.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { isCancel, select, spinner } from "@clack/prompts";
22
import { dlxCommand } from "nypm";
33
import type { PackageManagerName } from "nypm";
44

5-
import { runCommandShellSync } from "./run-command";
5+
import { runCommandSync } from "./run-command";
66

77
const ultraciteSkillRepo = "haydenbleasel/ultracite";
88

@@ -54,14 +54,15 @@ export const maybeInstallUltraciteSkill = async ({
5454
return false;
5555
}
5656

57-
const command = buildUltraciteSkillInstallCommand(packageManager);
57+
const fullCommand = buildUltraciteSkillInstallCommand(packageManager);
58+
const [command, ...args] = fullCommand.split(" ");
5859
const s = spinner();
5960

6061
if (!quiet) {
6162
s.start("Installing the Ultracite skill...");
6263
}
6364

64-
const result = runCommandShellSync(command, {
65+
const result = runCommandSync(command, args, {
6566
stdio: "pipe",
6667
});
6768
const didInstall = !result.error && result.status === 0;

0 commit comments

Comments
 (0)