Skip to content

Commit aea9227

Browse files
authored
polish(format): improv format check help (v10.1) (#6056)
* polish(format): improve format check CLI * update CHANGELOG.md
1 parent 96fdd85 commit aea9227

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#### :nail_care: Polish
2424

2525
- Better error message for extension point https://github.com/rescript-lang/rescript-compiler/pull/6057
26+
- Improve format check help https://github.com/rescript-lang/rescript-compiler/pull/6056
2627

2728
# 10.1.3
2829

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)