Skip to content

Commit 4c0d31d

Browse files
committed
fixup! tools: notify user if format-md needs to be run
1 parent ddb62b6 commit 4c0d31d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

tools/lint-md/lint-md.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29332,6 +29332,10 @@ const linter = unified()
2933229332

2933329333
paths.forEach(async (path) => {
2933429334
const file = await read(path);
29335+
// We need to calculate `fileContents` before running `linter.process(files)`
29336+
// because `linter.process(files)` mutates `file` and returns it as `result`.
29337+
// So we won't be able to use `file` after that to see if its contents have
29338+
// changed as they will have been altered to the changed version.
2933529339
const fileContents = file.toString();
2933629340
const result = await linter.process(file);
2933729341
if (format) {

tools/lint-md/lint-md.src.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ const linter = unified()
2828

2929
paths.forEach(async (path) => {
3030
const file = await read(path);
31+
// We need to calculate `fileContents` before running `linter.process(files)`
32+
// because `linter.process(files)` mutates `file` and returns it as `result`.
33+
// So we won't be able to use `file` after that to see if its contents have
34+
// changed as they will have been altered to the changed version.
3135
const fileContents = file.toString();
3236
const result = await linter.process(file);
3337
if (format) {

0 commit comments

Comments
 (0)