1
1
mirror of https://github.com/primer/css.git synced 2024-12-23 22:24:11 +03:00
css/tools/stylelint-selector-no-utility/prepare.js

25 lines
700 B
JavaScript

const {join} = require('path')
const {writeFile} = require('fs-extra')
const utilities = require('@primer/css/build/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
})