-
-
Notifications
You must be signed in to change notification settings - Fork 303
Expand file tree
/
Copy pathexternal-commands.test.ts
More file actions
65 lines (55 loc) · 1.79 KB
/
external-commands.test.ts
File metadata and controls
65 lines (55 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { describe, expect, it } from "bun:test";
import { mkdir, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { setupOxc } from "../src/helpers/addons/oxc-setup";
import { installDependencies } from "../src/helpers/core/install-dependencies";
import { getPackageExecutionArgs } from "../src/utils/package-runner";
import { SMOKE_DIR } from "./setup";
describe("External Command Guards", () => {
it("should split quoted args correctly", () => {
const args = getPackageExecutionArgs(
"bun",
`get-db@latest --yes --ref "sbA3tIe" --name test-db`,
);
expect(args).toEqual([
"bunx",
"get-db@latest",
"--yes",
"--ref",
"sbA3tIe",
"--name",
"test-db",
]);
});
it("should skip dependency installation when test mode is enabled", async () => {
const result = await installDependencies({
projectDir: SMOKE_DIR,
packageManager: "bun",
});
expect(result.isOk()).toBe(true);
});
it("should update package.json without running oxc init in test mode", async () => {
const projectDir = join(SMOKE_DIR, "oxc-skip");
await mkdir(projectDir, { recursive: true });
const pkgJsonPath = join(projectDir, "package.json");
await writeFile(
pkgJsonPath,
JSON.stringify(
{
name: "oxc-skip",
version: "0.0.0",
scripts: {},
devDependencies: {},
},
null,
2,
),
);
const result = await setupOxc(projectDir, "bun");
expect(result.isOk()).toBe(true);
const updated = await Bun.file(pkgJsonPath).json();
expect(updated.scripts?.check).toBe("oxlint && oxfmt --write");
expect(updated.devDependencies?.oxlint).toBeDefined();
expect(updated.devDependencies?.oxfmt).toBeDefined();
});
});