2020-11-03 13:04:24 +08:00
|
|
|
const fs = require('fs').promises
|
|
|
|
const path = require('path')
|
|
|
|
const { camelCase } = require('lodash')
|
|
|
|
|
|
|
|
;(async () => {
|
|
|
|
const srcPath = path.resolve(__dirname, '..', 'src')
|
|
|
|
const files = await fs.opendir(
|
|
|
|
srcPath
|
|
|
|
)
|
2020-12-07 00:13:47 +08:00
|
|
|
const code = []
|
2020-11-03 13:04:24 +08:00
|
|
|
for await (const file of files) {
|
|
|
|
if (file.isDirectory() && !file.name.startsWith('_')) {
|
|
|
|
if (await fs.stat(path.resolve(srcPath, file.name, 'styles')).then(() => false).catch(() => {
|
|
|
|
return true
|
|
|
|
})) continue
|
2020-12-07 00:13:47 +08:00
|
|
|
code.push(`export {
|
2020-11-03 13:04:24 +08:00
|
|
|
${camelCase(file.name)}Dark,
|
|
|
|
${camelCase(file.name)}Light
|
2020-12-07 00:13:47 +08:00
|
|
|
} from './${file.name}/styles'\n`)
|
2020-11-03 13:04:24 +08:00
|
|
|
// await fs.writeFile(path.resolve(srcPath, file.name, 'styles', 'index.js'), code)
|
|
|
|
}
|
|
|
|
}
|
2020-12-07 00:13:47 +08:00
|
|
|
code.sort()
|
|
|
|
console.log(code.join(''))
|
2020-11-03 13:04:24 +08:00
|
|
|
})()
|