mirror of
https://github.com/primer/css.git
synced 2024-11-27 09:45:45 +03:00
chore: get repository field from package.json
This commit is contained in:
parent
f55178b667
commit
3f4d58f7f6
@ -2,15 +2,15 @@ const each = require('./each')
|
|||||||
|
|
||||||
module.exports = function addSource(options = {}) {
|
module.exports = function addSource(options = {}) {
|
||||||
const {namespace = 'data'} = options
|
const {namespace = 'data'} = options
|
||||||
for (const key of ['branch', 'repo']) {
|
for (const key of ['branch', 'repository']) {
|
||||||
if (!options[key]) {
|
if (!options[key]) {
|
||||||
throw new Error(`addSource() plugin requires options.${key} (got ${JSON.stringify(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) => {
|
return each((file, source) => {
|
||||||
if (file[namespace]) {
|
if (file[namespace]) {
|
||||||
file[namespace].source = `https://github.com/${repo}/tree/${branch}/modules/${source}`
|
file[namespace].source = `${repository}/tree/${branch}/modules/${source}`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ const filter = require('metalsmith-filter')
|
|||||||
const frontmatter = require('metalsmith-matters')
|
const frontmatter = require('metalsmith-matters')
|
||||||
const watch = require('metalsmith-watch')
|
const watch = require('metalsmith-watch')
|
||||||
|
|
||||||
|
const {repository} = require('../package.json')
|
||||||
const addPackageMeta = require('./add-package-meta')
|
const addPackageMeta = require('./add-package-meta')
|
||||||
const {extractPackages, writePackagesJSON} = require('./extract-packages-json')
|
const {extractPackages, writePackagesJSON} = require('./extract-packages-json')
|
||||||
const addSource = require('./add-source')
|
const addSource = require('./add-source')
|
||||||
@ -23,7 +24,6 @@ module.exports = function sync(options = {}) {
|
|||||||
let files
|
let files
|
||||||
|
|
||||||
const metal = Metalsmith(process.cwd())
|
const metal = Metalsmith(process.cwd())
|
||||||
.source('../modules/primer')
|
|
||||||
.destination('pages/css')
|
.destination('pages/css')
|
||||||
.clean(false)
|
.clean(false)
|
||||||
.frontmatter(false)
|
.frontmatter(false)
|
||||||
@ -43,7 +43,7 @@ module.exports = function sync(options = {}) {
|
|||||||
.use(
|
.use(
|
||||||
addSource({
|
addSource({
|
||||||
branch: 'master',
|
branch: 'master',
|
||||||
repo: 'primer/primer',
|
repository,
|
||||||
log
|
log
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user