Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 15 additions & 2 deletions jscomp/build_tests/cli_help/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@ assert.match(
// FIXME: Should be 0
assert.equal(out.status, 1);

// FIXME: Has the same problem with `rescript -w`
out = child_process.spawnSync(`../../../rescript`, ["-w", "--help"], {
encoding: "utf8",
cwd: __dirname,
});
assert.equal(out.stdout, ">>>> Start compiling\n" + buildHelp);
assert.match(
out.stderr,
new RegExp(
"Uncaught Exception Error: ENOENT: no such file or directory, watch 'bsconfig.json'\n"
)
);

// Shows build help with -h arg
out = child_process.spawnSync(`../../../rescript`, ["build", "-h"], {
encoding: "utf8",
Expand Down Expand Up @@ -153,12 +166,12 @@ assert.equal(out.stderr, `Error: Unknown command or flag "built".\n` + cliHelp);
assert.equal(out.status, 2);

// Shows cli help with unknown args
out = child_process.spawnSync(`../../../rescript`, ["-w"], {
out = child_process.spawnSync(`../../../rescript`, ["-foo"], {
encoding: "utf8",
cwd: __dirname,
});
assert.equal(out.stdout, "");
assert.equal(out.stderr, `Error: Unknown command or flag "-w".\n` + cliHelp);
assert.equal(out.stderr, `Error: Unknown command or flag "-foo".\n` + cliHelp);
assert.equal(out.status, 2);

// Shows clean help with --help arg
Expand Down
8 changes: 7 additions & 1 deletion rescript
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,10 @@ process.on("SIGHUP", exitProcess);

const maybeSubcommand = process_argv[2];

if (maybeSubcommand === "build" && process_argv.includes("-w")) {
if (
(maybeSubcommand === "build" && process_argv.includes("-w")) ||
maybeSubcommand === "-w"
) {
// All clients of type MiniWebSocket
/**
* @type {any[]}
Expand Down Expand Up @@ -240,6 +243,9 @@ if (maybeSubcommand === "build" && process_argv.includes("-w")) {
let watchers = [];

const delegatedArgs = process_argv.slice(2);
if (maybeSubcommand === "-w") {
delegatedArgs.unshift("build");
}
verbose = delegatedArgs.includes("-verbose");

var wsParamIndex = delegatedArgs.indexOf("-ws");
Expand Down