Files
bun.sh/test/cli/install/bad-workspace.test.ts
Zack Radisic 303f86af41 Glob support for workspace names in bun install (#10462)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: zackradisic <zackradisic@users.noreply.github.com>
2024-05-01 11:01:55 -07:00

39 lines
872 B
TypeScript

import { spawnSync } from "bun";
import { afterEach, beforeEach, expect, test } from "bun:test";
import { mkdtempSync, realpathSync, rmSync, writeFileSync } from "fs";
import { bunExe, bunEnv } from "harness";
import { join } from "path";
import { tmpdir } from "os";
let cwd: string;
beforeEach(() => {
cwd = mkdtempSync(join(realpathSync(tmpdir()), "bad-workspace.test"));
});
test("bad workspace path", () => {
writeFileSync(
`${cwd}/package.json`,
JSON.stringify(
{
name: "hey",
workspaces: ["i-dont-exist"],
},
null,
2,
),
);
const { stderr, exitCode } = spawnSync({
cmd: [bunExe(), "install"],
cwd,
env: bunEnv,
stderr: "pipe",
stdout: "pipe",
});
const text = stderr!.toString();
expect(text).toContain('Workspace not found "i-dont-exist"');
expect(exitCode).toBe(1);
});