1
1
mirror of https://github.com/primer/css.git synced 2024-11-23 11:27:26 +03:00

chore: get repository field from package.json

This commit is contained in:
Shawn Allen 2019-02-04 13:29:14 -08:00
parent f55178b667
commit 3f4d58f7f6
2 changed files with 5 additions and 5 deletions

View File

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

View File

@ -3,6 +3,7 @@ const filter = require('metalsmith-filter')
const frontmatter = require('metalsmith-matters')
const watch = require('metalsmith-watch')
const {repository} = require('../package.json')
const addPackageMeta = require('./add-package-meta')
const {extractPackages, writePackagesJSON} = require('./extract-packages-json')
const addSource = require('./add-source')
@ -23,7 +24,6 @@ module.exports = function sync(options = {}) {
let files
const metal = Metalsmith(process.cwd())
.source('../modules/primer')
.destination('pages/css')
.clean(false)
.frontmatter(false)
@ -43,7 +43,7 @@ module.exports = function sync(options = {}) {
.use(
addSource({
branch: 'master',
repo: 'primer/primer',
repository,
log
})
)