docsify/build/css.js
Joe Pea 7bbf13d9bd
Ensure code format (#2138)
* chore: add missing Vue support for Vercel builds

* refactor: move some functions and module-level state into classes as private methods and properties to start to encapsulate Docsify

Also some small tweaks:

- move initGlobalAPI out of Docsify.js to start to encapsulate Docsify
- move ajax to utils folder
- fix some type definitions and improve content in some JSDoc comments
- use concise class field syntax
- consolidate duplicate docsify-ignore comment removal code

This handles a task in [Simplify and modernize Docsify](https://github.com/docsifyjs/docsify/issues/2104), as well as works towards [Encapsulating Docsify](https://github.com/docsifyjs/docsify/issues/2135).

* chore: add prettier code format check to our lint script, and add a prettier script for manually formatting the whole code base

* chore: update issue/pr templates

* chore: apply our format to the whole code base


---------

Co-authored-by: Koy <koy@ko8e24.top>
Co-authored-by: i544693 <369491420@qq.com>
2023-08-09 17:53:30 +08:00

49 lines
1.2 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)) {
const stylusBin = ['node_modules', 'stylus', 'bin', 'stylus'].join(
path.sep
);
let cmdargs = [
stylusBin,
`src/themes/${file}`,
'-u',
'autoprefixer-stylus',
];
cmdargs = [...cmdargs, ...args];
const 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;
}
});
});