1
1
mirror of https://github.com/primer/css.git synced 2024-11-30 19:53:11 +03:00
css/docs/lib/add-source.js
2018-12-17 15:26:50 -08:00

15 lines
471 B
JavaScript

const each = require('./each')
module.exports = function addSource(options = {}) {
const {namespace = 'data'} = options
for (const key of ['branch', 'repo']) {
if (!options[key]) {
throw new Error(`addSource() plugin requires options.${key} (got ${JSON.stringify(options[key])})`)
}
}
const {branch, repo} = options
return each((file, source) => {
file[namespace].source = `https://github.com/${repo}/tree/${branch}/modules/${source}`
})
}