2018-06-14 21:42:44 +00:00
|
|
|
// 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, 'styles')
|
|
|
|
const cssDirectory = path.join(__dirname, 'css')
|
|
|
|
|
2018-06-14 22:25:31 +00:00
|
|
|
// Walk recursively through styles directory
|
2018-06-14 21:42:44 +00:00
|
|
|
let files = klawSync(stylesDirectory, {nodir: true})
|
|
|
|
|
2018-06-14 22:25:31 +00:00
|
|
|
// Filter out any files that aren't .js files
|
2018-06-14 21:42:44 +00:00
|
|
|
files = files.filter(file => path.extname(file.path) === '.js')
|
|
|
|
|
2018-06-14 22:25:31 +00:00
|
|
|
// Iterate through all .js files
|
2018-06-14 21:42:44 +00:00
|
|
|
for (const file of files) {
|
2018-06-14 22:25:31 +00:00
|
|
|
// Requiring the .js files as the descriptor of the style
|
2018-06-14 21:42:44 +00:00
|
|
|
const descriptor = require(file.path)
|
2018-06-14 22:25:31 +00:00
|
|
|
// Creating the css path and generating the .user.css file with the options
|
2018-06-14 21:42:44 +00:00
|
|
|
const cssPath = path.join(cssDirectory, descriptor.folder, descriptor.entry)
|
|
|
|
userCss.create(cssPath, descriptor.options)
|
|
|
|
}
|