1
1
mirror of https://github.com/primer/css.git synced 2024-12-11 11:16:04 +03:00
css/docs-test/exceptions.js
2019-02-04 12:55:18 -08:00

27 lines
829 B
JavaScript

const {yellow, green, red} = require('colorette')
/**
* Each exception type may resolve to either:
*
* 1. A string, which will be treated as a message listed alongside the
* "excepted" path; or
*
* 2. A function in the form: `f(paths) : {pass:Boolean, message:String}`
*
* In the case of `moved(path)`, it returns a _function_ that checks for
* whether the provided path exists in `paths` and returns the appropriate
* status object with `pass` and `message` props.
*/
module.exports = {
removed: red('removed'),
deprecated: yellow('deprecated'),
redirect: url => `${green('redirect')}${url}`,
moved: path => paths => {
if (paths.includes(path)) {
return {pass: true, message: `${green(path)}`}
} else {
return {pass: false, message: `${red(path)} is missing`}
}
}
}