Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[editorial][CI] Ensure markdownlint has proper exit status #210

Merged
Merged
Changes from all commits
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
22 changes: 13 additions & 9 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const markdownlint = require("markdownlint");
const yaml = require("js-yaml");
const fs = require("fs");

let fileCount = 0,
issueCount = 0;
let numFilesProcessed = 0,
numFilesWithIssues = 0;

function markdownLintFile(file, encoding, callback) {
const config = yaml.load(fs.readFileSync("./.markdownlint.yaml", "utf8"));
Expand Down Expand Up @@ -33,9 +33,11 @@ function markdownLintFile(file, encoding, callback) {
.join("\n");
if (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);
});
}
Expand All @@ -47,11 +49,13 @@ function lintMarkdown() {
.src(markdownFiles)
.pipe(through2.obj(markdownLintFile))
.on("end", () => {
console.log(
`Processed ${fileCount} file${
fileCount == 1 ? "" : "s"
}, ${issueCount} had issues.`,
);
const fileOrFiles = "file" + (numFilesProcessed == 1 ? "" : "s");
const msg = `Processed ${numFilesProcessed} ${fileOrFiles}, ${numFilesWithIssues} had issues.`;
if (numFilesWithIssues > 0) {
throw new Error(msg);
} else {
console.log(msg);
}
});
}

Expand Down
Loading