1
Fork 0
userstyles/generate.js

27 lines
925 B
JavaScript
Executable File

// Generates all *.user.css styles.
// Require dependencies
// const fs = require('fs')
const klawSync = require('klaw-sync')
const path = require('path')
const userCss = require('usercss-creator')
// Define constants
const stylesDirectory = path.join(__dirname, 'sass')
const cssDirectory = path.join(__dirname, 'css')
// Walk recursively through styles directory
let files = klawSync(stylesDirectory, {nodir: true})
// Filter out any files that aren't .js files
files = files.filter(file => path.extname(file.path) === '.js')
// Iterate through all .js files
for (const file of files) {
// Requiring the .js files as the descriptor of the style
const descriptor = require(file.path)
// Creating the css path and generating the .user.css file with the options
const cssPath = path.join(cssDirectory, descriptor.folder, descriptor.entry)
userCss.create(cssPath, descriptor.options)
}