mirror of
https://github.com/primer/css.git
synced 2024-12-15 15:34:02 +03:00
22 lines
631 B
Plaintext
22 lines
631 B
Plaintext
|
#!/usr/bin/env node
|
||
|
const {dirname, join} = require('path')
|
||
|
const globby = require('globby')
|
||
|
const {exists, readFile, writeFile} = require('fs-extra')
|
||
|
|
||
|
Promise.all([
|
||
|
readFile('src/README.template.md', 'utf8'),
|
||
|
globby('src/*/index.scss')
|
||
|
]).then(async ([template, indexes]) => {
|
||
|
for (const indexPath of indexes) {
|
||
|
const dir = dirname(indexPath)
|
||
|
const parts = dir.split('/')
|
||
|
const bundle = parts.pop()
|
||
|
const readmePath = join(dir, 'README.md')
|
||
|
await writeFile(readmePath, getReadmeContents(bundle), 'utf8')
|
||
|
}
|
||
|
|
||
|
function getReadmeContents(bundle) {
|
||
|
return template.replace(/{bundle}/g, bundle)
|
||
|
}
|
||
|
})
|