Skip to content

Commit

Permalink
Print error messages to console
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenhuy committed Aug 22, 2019
1 parent d87aa79 commit 786caad
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,28 @@ const has_added_source_files = (Array.isArray(added_source_files) && added_sourc

// Make it more obvious that a PR is a work in progress and shouldn't be merged yet
if (danger.github.pr.title.includes("[WIP]")) {
fail("PR is classed as Work in Progress");
const msg = "PR is classed as Work in Progress";
console.error(msg);
fail(msg);
}

// Warn when there is a big PR
if (danger.github.pr.additions + danger.github.pr.deletions > 500) {
warn("This is a big PR, please consider splitting it up to ease code review.");
const msg = "This is a big PR, please consider splitting it up to ease code review.";
console.error(msg);
warn(msg);
}

// Modifying the changelog will probably get overwritten.
if (danger.git.modified_files.includes("CHANGELOG.md")) {
if (danger.github.pr.title.includes("#changelog")) {
warn("PR modifies CHANGELOG.md, which is a generated file. #changelog added to the title to suppress this warning.");
const msg = "PR modifies CHANGELOG.md, which is a generated file. #changelog added to the title to suppress this warning.";
console.error(msg);
warn(msg);
} else {
fail("PR modifies CHANGELOG.md, which is a generated file. Add #changelog to the title to suppress this failure.");
const msg = "PR modifies CHANGELOG.md, which is a generated file. Add #changelog to the title to suppress this failure.";
console.error(msg);
fail(msg);
}
}

Expand Down Expand Up @@ -51,7 +59,9 @@ function check_file_header(files_to_check, license) {
schedule(async () => {
const content = await danger.github.utils.fileContents(file);
if (!content.includes("Pinterest, Inc.")) {
fail("Please ensure license is correct for " + filename +":\n```" + full_license(license, filename) + "\n```");
const msg = "Please ensure license is correct for " + filename +":\n```" + full_license(license, filename) + "\n```";
console.error(msg);
fail(msg);
}
});
}
Expand Down

0 comments on commit 786caad

Please sign in to comment.