Skip to content

Commit 60f6c9d

Browse files
authored
polish(format): improve format check CLI (rescript-lang#5893)
1 parent 2fb38ce commit 60f6c9d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

scripts/rescript_format.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ the formatted code to stdout in ReScript syntax`,
4343
[
4444
"-check",
4545
{ kind: "Unit", data: { kind: "Unit_set", data: check } },
46-
"Check formatting only",
46+
"Check formatting for file or the whole project. Use `-all` to check the whole project",
4747
],
4848
];
4949
var formattedStdExtensions = [".res", ".resi", ".ml", ".mli"];
@@ -130,6 +130,16 @@ async function main(argv, rescript_exe, bsc_exe) {
130130

131131
var format_project = format.val;
132132
var use_stdin = stdin.val;
133+
134+
// Only -check arg
135+
// Require: -all or path to a file
136+
if (check.val && !format_project && files.length == 0) {
137+
console.error(
138+
"format check require path to a file or use `-all` to check the whole project"
139+
);
140+
process.exit(2);
141+
}
142+
133143
if (format_project) {
134144
if (use_stdin || files.length !== 0) {
135145
console.error("format -all can not be in use with other flags");

0 commit comments

Comments
 (0)