Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bin/moshpit-name.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ if (sub === "list") {
}
if (limitFlags === 1) limit = parsedLimit;

if (rest.includes("-") && !(rest.length === 1 && rest[0] === "-")) {
exitInputError('"-" must be the only input when reading from stdin');
}
const input = rest[0] === "-" || !rest.length ? await readStdin() : rest.join("\n");
const parsed = parseTldList(input, limit);
if (ndjson) {
Expand Down
7 changes: 7 additions & 0 deletions test/cli.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ test("NDJSON validation errors stay machine-readable", () => {
error: '"-" must be the only input when reading from stdin',
});

const listMarker = run(["list", "-", "eggs", "--json"], "oranges\n");
assert.equal(listMarker.status, 1);
assert.equal(listMarker.stderr, "");
assert.deepEqual(JSON.parse(listMarker.stdout), {
error: '"-" must be the only input when reading from stdin',
});

const limit = run(["list", "-", "--limit", "0", "--ndjson"], "eggs\n");
assert.equal(limit.status, 1);
assert.equal(limit.stderr, "");
Expand Down
Loading