[editorial][CI] Ensure markdownlint has proper exit status (#210)
Co-authored-by: Josh Suereth <joshuasuereth@google.com>
This commit is contained in:
parent
a5509c690a
commit
73408c933e
22
gulpfile.js
22
gulpfile.js
|
|
@ -4,8 +4,8 @@ const markdownlint = require("markdownlint");
|
||||||
const yaml = require("js-yaml");
|
const yaml = require("js-yaml");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
|
||||||
let fileCount = 0,
|
let numFilesProcessed = 0,
|
||||||
issueCount = 0;
|
numFilesWithIssues = 0;
|
||||||
|
|
||||||
function markdownLintFile(file, encoding, callback) {
|
function markdownLintFile(file, encoding, callback) {
|
||||||
const config = yaml.load(fs.readFileSync("./.markdownlint.yaml", "utf8"));
|
const config = yaml.load(fs.readFileSync("./.markdownlint.yaml", "utf8"));
|
||||||
|
|
@ -33,9 +33,11 @@ function markdownLintFile(file, encoding, callback) {
|
||||||
.join("\n");
|
.join("\n");
|
||||||
if (resultString) {
|
if (resultString) {
|
||||||
console.log(resultString);
|
console.log(resultString);
|
||||||
issueCount++;
|
numFilesWithIssues++;
|
||||||
|
// Don't report an error yet so that other files can be checked:
|
||||||
|
// callback(new Error('...'));
|
||||||
}
|
}
|
||||||
fileCount++;
|
numFilesProcessed++;
|
||||||
callback(null, file);
|
callback(null, file);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -47,11 +49,13 @@ function lintMarkdown() {
|
||||||
.src(markdownFiles)
|
.src(markdownFiles)
|
||||||
.pipe(through2.obj(markdownLintFile))
|
.pipe(through2.obj(markdownLintFile))
|
||||||
.on("end", () => {
|
.on("end", () => {
|
||||||
console.log(
|
const fileOrFiles = "file" + (numFilesProcessed == 1 ? "" : "s");
|
||||||
`Processed ${fileCount} file${
|
const msg = `Processed ${numFilesProcessed} ${fileOrFiles}, ${numFilesWithIssues} had issues.`;
|
||||||
fileCount == 1 ? "" : "s"
|
if (numFilesWithIssues > 0) {
|
||||||
}, ${issueCount} had issues.`,
|
throw new Error(msg);
|
||||||
);
|
} else {
|
||||||
|
console.log(msg);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue