Skip to content

Commit

Permalink
Merge pull request #102 from danger/package-json-yarn-lock-warning
Browse files Browse the repository at this point in the history
Warn if changes to package.json and not yarn.lock
  • Loading branch information
orta authored Jan 18, 2017
2 parents 8ca6537 + 181fd37 commit e117d03
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions dangerfile.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
// import { danger, warn } from "danger"
import fs from "fs"
import includes from "lodash.includes"

// Request a CHANGELOG entry if not declared #trivial
const hasChangelog = danger.git.modified_files.includes("changelog.md")
const isTrivial = (danger.github.pr.body + danger.github.pr.title).includes("#trivial")
const hasChangelog = includes(danger.git.modified_files, "changelog.md")
const isTrivial = includes((danger.github.pr.body + danger.github.pr.title), "#trivial")
if (!hasChangelog && !isTrivial) {
warn("Please add a changelog entry for your changes.")

// Politely ask for their name on the entry too
const changelogDiff = danger.git.diffForFile("changelog.md")
const contributorName = danger.github.pr.user.login
if (changelogDiff && changelogDiff.indexOf(contributorName) === -1) {
if (changelogDiff && !includes(changelogDiff, contributorName)) {
warn("Please add your GitHub name to the changelog entry, so we can attribute you.")
}
}

// Warns if there are changes to package.json without changes to yarn.lock.
const packageChanged = includes(danger.git.modified_files, "package.json")
const lockfileChanged = includes(danger.git.modified_files, "yarn.lock")
if (packageChanged && !lockfileChanged) {
const message = "Changes were made to package.json, but not to yarn.lock"
const idea = "Perhaps you need to run `yarn install`?"
warn(`${message} - <i>${idea}</i>`)
}

0 comments on commit e117d03

Please sign in to comment.