aboutsummaryrefslogtreecommitdiff
path: root/test/cli/run/bunfig.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'test/cli/run/bunfig.test.ts')
-rw-r--r--test/cli/run/bunfig.test.ts47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/cli/run/bunfig.test.ts b/test/cli/run/bunfig.test.ts
index 0c8a23c65..efb4355ac 100644
--- a/test/cli/run/bunfig.test.ts
+++ b/test/cli/run/bunfig.test.ts
@@ -58,6 +58,17 @@ describe("config", () => {
}
});
+ test("read --config *.json absolute path", () => {
+ {
+ const dir = tempDirWithFiles("dotenv", {
+ "bun2.json": `{"define": { "caterpillar": "'butterfly'" }}`,
+ "index.ts": "console.log(caterpillar);",
+ });
+ const { stdout } = bunRun(`${dir}/index.ts`, {}, { flags: ["-c", `${dir}/bun2.json`] });
+ expect(stdout).toBe("butterfly");
+ }
+ });
+
test("read --config *.toml", () => {
{
const dir = tempDirWithFiles("dotenv", {
@@ -68,6 +79,7 @@ describe("config", () => {
expect(stdout).toBe("butterfly");
}
});
+
test("read -c *.toml", () => {
{
const dir = tempDirWithFiles("dotenv", {
@@ -78,4 +90,39 @@ describe("config", () => {
expect(stdout).toBe("butterfly");
}
});
+
+ test("read --config absolute path", () => {
+ {
+ const dir = tempDirWithFiles("dotenv", {
+ "bun2.toml": `[define]\n"caterpillar" = "'butterfly'"`,
+ "index.ts": "console.log(caterpillar);",
+ });
+ const { stdout } = bunRun(`${dir}/index.ts`, {}, { flags: ["-c", `${dir}/bun2.toml`] });
+ expect(stdout).toBe("butterfly");
+ }
+ });
+
+ test("fail if --config absolute path can't be found", () => {
+ {
+ const dir = tempDirWithFiles("dotenv", {
+ "index.ts": "console.log(caterpillar);",
+ });
+
+ {
+ expect(() => {
+ bunRun(`${dir}/index.ts`, {}, { flags: ["-c", `${dir}/notreal.json`] });
+ }).toThrow();
+ }
+ }
+ });
+ // test("read --config absolute path", () => {
+ // {
+ // const dir = tempDirWithFiles("dotenv", {
+ // "bun2.toml": `[define]\n"caterpillar" = "'butterfly'"`,
+ // "index.ts": "console.log(caterpillar);",
+ // });
+ // const { stdout } = bunRun(`${dir}/index.ts`, {}, { flags: ["-c", "bun2.toml"] });
+ // expect(stdout).toBe("butterfly");
+ // }
+ // });
});