mirror of
https://github.com/primer/css.git
synced 2024-12-04 14:59:16 +03:00
25 lines
689 B
JavaScript
25 lines
689 B
JavaScript
const {join} = require('path')
|
|
const {writeFile} = require('fs-extra')
|
|
const utilities = require('primer-utilities')
|
|
const match = require('./match')
|
|
|
|
const classes = utilities.cssstats.selectors.values.reduce((set, selector) => {
|
|
const matches = match(selector)
|
|
if (matches) {
|
|
for (const klass of Array.from(matches)) {
|
|
set.add(klass)
|
|
}
|
|
}
|
|
return set
|
|
}, new Set())
|
|
|
|
const data = JSON.stringify(Array.from(classes).sort(), null, 2)
|
|
const filename = join(__dirname, 'classes.json')
|
|
|
|
writeFile(filename, data, 'utf8')
|
|
.then(() => console.warn(`wrote ${classes.size} classes to: ${filename}`))
|
|
.catch(error => {
|
|
console.error(error)
|
|
process.exitCode = 1
|
|
})
|