Skip to content

Commit

Permalink
feat: Adds support for more recent versions of the danger results
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed Jun 4, 2018
1 parent 77f5d3f commit 0cf5b8e
Show file tree
Hide file tree
Showing 3 changed files with 388 additions and 174 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -46,7 +46,7 @@
"babel-preset-env": "^1.6.0",
"commitizen": "^2.9.6",
"cz-conventional-changelog": "^2.0.0",
"danger": "2.0.0-alpha.13",
"danger": "3.7.15",
"husky": "^0.13.3",
"jest": "^20.0.1",
"lint-staged": "^3.4.1",
Expand Down Expand Up @@ -88,6 +88,6 @@
]
},
"dependencies": {
"markdown-spellcheck": "^0.11.0"
"markdown-spellcheck": "^1.3.1"
}
}
14 changes: 10 additions & 4 deletions src/index.ts
Expand Up @@ -28,7 +28,7 @@ const implicitSettingsFilename = "spellcheck.json"
*/
export interface SpellCheckOptions {
settings?: string
ignore?: string[],
ignore?: string[]
whitelistFiles?: string[]
}

Expand Down Expand Up @@ -134,8 +134,8 @@ export const getSpellcheckSettings = async (options?: SpellCheckOptions): Promis
ignoredWords = ignoredWords.concat(localSettings.ignore)
whitelistedMarkdowns = whitelistedMarkdowns.concat(localSettings.whitelistFiles)
// from function
ignoredWords = ignoredWords.concat(options && options.ignore || [])
whitelistedMarkdowns = whitelistedMarkdowns.concat(options && options.whitelistFiles || [])
ignoredWords = ignoredWords.concat((options && options.ignore) || [])
whitelistedMarkdowns = whitelistedMarkdowns.concat((options && options.whitelistFiles) || [])
const hasLocalSettings = !!(localSettings.ignore.length || localSettings.whitelistFiles.length)
return { ignore: ignoredWords, whitelistFiles: whitelistedMarkdowns, hasLocalSettings }
}
Expand Down Expand Up @@ -165,7 +165,13 @@ export default async function spellcheck(options?: SpellCheckOptions) {
}
}

const hasTypos = results.markdowns.find(m => m.includes("### Typos for"))
const hasTypos = results.markdowns.find(m => {
if (typeof m === "string") {
return (m as string).includes("### Typos for")
} else {
return m.message.includes("### Typos for")
}
})

// https://github.com/artsy/artsy-danger/edit/master/spellcheck.json
if (hasTypos && (settings.hasLocalSettings || options)) {
Expand Down

0 comments on commit 0cf5b8e

Please sign in to comment.