test(cli): clean up temp install artifact fixture

This commit is contained in:
sonwr
2026-03-03 12:00:47 +09:00
parent 307043c303
commit bf98912d03
@@ -19,46 +19,50 @@ describe("npm install artifact behavior", () => {
test("links npm bin commands to the wrapper during local install", async () => {
const tmp = await fs.mkdtemp(path.join(os.tmpdir(), "kilo-install-artifact-"))
const pkg = path.join(tmp, "pkg")
const bin = path.join(pkg, "bin")
const prefix = path.join(tmp, "prefix")
await fs.mkdir(bin, { recursive: true })
await fs.mkdir(prefix, { recursive: true })
await fs.copyFile(wrapper, path.join(bin, "kilo"))
await Bun.write(
path.join(pkg, "package.json"),
JSON.stringify(
{
name: "kilo-install-artifact-repro",
version: "1.0.0",
bin: {
kilo: "./bin/kilo",
kilocode: "./bin/kilo",
try {
const pkg = path.join(tmp, "pkg")
const bin = path.join(pkg, "bin")
const prefix = path.join(tmp, "prefix")
await fs.mkdir(bin, { recursive: true })
await fs.mkdir(prefix, { recursive: true })
await fs.copyFile(wrapper, path.join(bin, "kilo"))
await Bun.write(
path.join(pkg, "package.json"),
JSON.stringify(
{
name: "kilo-install-artifact-repro",
version: "1.0.0",
bin: {
kilo: "./bin/kilo",
kilocode: "./bin/kilo",
},
},
},
null,
2,
),
)
null,
2,
),
)
await $`npm install --prefix ${prefix} ${pkg} --no-package-lock --ignore-scripts --no-audit --no-fund`.quiet()
await $`npm install --prefix ${prefix} ${pkg} --no-package-lock --ignore-scripts --no-audit --no-fund`.quiet()
const commands = ["kilo", "kilocode"]
for (const name of commands) {
const link = path.join(prefix, "node_modules", ".bin", name)
const stat = await fs.lstat(link)
expect(stat.isSymbolicLink() || stat.isFile()).toBe(true)
const commands = ["kilo", "kilocode"]
for (const name of commands) {
const link = path.join(prefix, "node_modules", ".bin", name)
const stat = await fs.lstat(link)
expect(stat.isSymbolicLink() || stat.isFile()).toBe(true)
}
const hidden = path.join(prefix, "node_modules", ".bin", ".kilo")
const exists = await fs
.access(hidden)
.then(() => true)
.catch(() => false)
if (!exists) return
const stat = await fs.lstat(hidden)
expect(stat.isFile() || stat.isSymbolicLink()).toBe(true)
if (!stat.isSymbolicLink()) expect(stat.size).toBeGreaterThan(0)
} finally {
await fs.rm(tmp, { recursive: true, force: true })
}
const hidden = path.join(prefix, "node_modules", ".bin", ".kilo")
const exists = await fs
.access(hidden)
.then(() => true)
.catch(() => false)
if (!exists) return
const stat = await fs.lstat(hidden)
expect(stat.isFile() || stat.isSymbolicLink()).toBe(true)
if (!stat.isSymbolicLink()) expect(stat.size).toBeGreaterThan(0)
})
})