|
1 | 1 | import path from "path"; |
2 | | -import { exec } from "child_process"; |
| 2 | +import { execFile } from "child_process"; |
3 | 3 | import { promisify } from "util"; |
4 | 4 | import { describe, expect, it } from "vitest"; |
5 | 5 | import packageJson from "../../package.json" with { type: "json" }; |
6 | 6 |
|
7 | | -const execAsync = promisify(exec); |
| 7 | +const execFileAsync = promisify(execFile); |
8 | 8 | const CLI_PATH = path.join(import.meta.dirname, "..", "..", "dist", "index.js"); |
9 | 9 |
|
10 | 10 | describe("CLI entrypoint", () => { |
11 | 11 | it("should handle version request", async () => { |
12 | | - const { stdout, stderr } = await execAsync(`${process.execPath} ${CLI_PATH} --version`); |
| 12 | + const { stdout, stderr } = await execFileAsync(process.execPath, [CLI_PATH, "--version"]); |
13 | 13 | expect(stdout).toContain(packageJson.version); |
14 | 14 | expect(stderr).toEqual(""); |
15 | 15 | }); |
16 | 16 |
|
17 | 17 | it("should handle help request", async () => { |
18 | | - const { stdout, stderr } = await execAsync(`${process.execPath} ${CLI_PATH} --help`); |
| 18 | + const { stdout, stderr } = await execFileAsync(process.execPath, [CLI_PATH, "--help"]); |
19 | 19 | expect(stdout).toContain("For usage information refer to the README.md"); |
20 | 20 | expect(stderr).toEqual(""); |
21 | 21 | }); |
22 | 22 |
|
23 | 23 | it("should handle dry run request", async () => { |
24 | | - const { stdout, stderr } = await execAsync(`${process.execPath} ${CLI_PATH} --dryRun`); |
| 24 | + const { stdout, stderr } = await execFileAsync(process.execPath, [CLI_PATH, "--dryRun"]); |
25 | 25 | expect(stdout).toContain("Configuration:"); |
26 | 26 | expect(stdout).toContain("Enabled tools:"); |
27 | 27 | expect(stderr).toEqual(""); |
|
0 commit comments