docsify/build/css.js
Joe Pea 62d756c447 refactor: convert to ES Modules and remove traces of CommonJS except in Rollup config because some dependencies are still CommonJS
BREAKING: The new project layout might break in some tooling setups.

We've added an exports field to `package.json` to specify where
statements like `import ... from 'docsify'` will import from, and left
the `main` and `unpkg` fields as-is for backwards compatibility with the
global <script> import method. Most people who use a non-module
`<script>` tag to import Docsify will not notice a difference. Anyone
else who is importing Docsify into a specilized build setup using
`import` statements has a chance of being broken, so we've marked this
as BREAKING.
2023-06-29 19:02:08 -07:00

49 lines
1.4 KiB
JavaScript

import fs from 'fs'
import path from 'path'
import {spawn} from 'child_process'
const relative = path => new URL(path, import.meta.url);
const args = process.argv.slice(2)
fs.readdir(relative('../src/themes'), (err, files) => {
if (err) {
console.error('err', err)
process.exit(1)
}
files.map(async (file) => {
if (/\.styl/g.test(file)) {
var stylusCMD;
const stylusBin = ['node_modules', 'stylus', 'bin', 'stylus'].join(path.sep)
var cmdargs = [
stylusBin,
`src/themes/${file}`,
'-u',
'autoprefixer-stylus'
]
cmdargs = cmdargs.concat(args)
stylusCMD = spawn('node', cmdargs, { shell: true })
stylusCMD.stdout.on('data', (data) => {
console.log(`[Stylus Build ] stdout: ${data}`);
});
stylusCMD.stderr.on('data', (data) => {
console.error(`[Stylus Build ] stderr: ${data}`);
});
stylusCMD.on('close', (code) => {
const message = `[Stylus Build ] child process exited with code ${code}`
if (code !== 0) {
console.error(message);
process.exit(code)
}
console.log(message);
});
} else {
return
}
})
})