Skip to content

Commit 0eaafa0

Browse files
authored
fix(cli): accept stdin script marker (#358)
1 parent 21991c7 commit 0eaafa0

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

test/run-options.test.mjs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { closeSync, mkdtempSync, openSync, readFileSync, writeFileSync } from "n
33
import { fileURLToPath } from "node:url";
44
import { tmpdir } from "node:os";
55
import { join } from "node:path";
6-
import { spawn } from "node:child_process";
6+
import { spawn, spawnSync } from "node:child_process";
77
import test from "node:test";
88

99
const BIN = fileURLToPath(new URL("../bin/moshcode.mjs", import.meta.url));
@@ -75,6 +75,17 @@ test("run - reads the script from stdin", async () => {
7575
assert.match(result.stdout, /from stdin/);
7676
});
7777

78+
test("run accepts - before --dry-run", () => {
79+
const result = spawnSync(process.execPath, [BIN, "run", "-", "--dry-run"], {
80+
encoding: "utf8",
81+
input: 'say("from stdin");\n',
82+
});
83+
84+
assert.equal(result.status, 0);
85+
assert.equal(result.stderr, "");
86+
assert.match(result.stdout, /from stdin/);
87+
});
88+
7889
test("run accepts equals-form max option", async () => {
7990
const result = await run(["--max=1", "--dry-run"]);
8091

0 commit comments

Comments
 (0)