Recursive building set up.
This commit is contained in:
parent
e6204dade4
commit
3cab1d9b59
1 changed files with 20 additions and 5 deletions
25
build.js
25
build.js
|
@ -131,11 +131,23 @@ async function downloadFiles() {
|
|||
}
|
||||
|
||||
async function buildScript(scriptPath) {
|
||||
const srcDir = path.dirname(scriptPath);
|
||||
const scriptName = path.basename(scriptPath, ".user.js");
|
||||
const metaPath = path.join(srcDir, `${scriptName}.meta.js`);
|
||||
const outPath = path.join(outDir, `${scriptName}.user.js`);
|
||||
const tempPath = path.join(outDir, `${scriptName}.user.temp.js`);
|
||||
const minifiedPath = path.join(outDir, `${scriptName}.min.user.js`);
|
||||
const metaPath = path.join(srcDir, scriptName + `.meta.js`);
|
||||
let outdDir = [outDir, srcDir.replace(/^src(\\|\/)?/, "")];
|
||||
const outPath = path.join(...outdDir, `${scriptName}.user.js`);
|
||||
const tempPath = path.join(...outdDir, `${scriptName}.user.temp.js`);
|
||||
const minifiedPath = path.join(...outdDir, `${scriptName}.min.user.js`);
|
||||
console.log({
|
||||
srcDir,
|
||||
outdDir,
|
||||
scriptPath,
|
||||
scriptName,
|
||||
metaPath,
|
||||
outPath,
|
||||
tempPath,
|
||||
minifiedPath,
|
||||
});
|
||||
|
||||
if (!fs.existsSync(metaPath)) {
|
||||
console.error(`Meta file not found: ${metaPath}`);
|
||||
|
@ -183,8 +195,11 @@ async function buildScript(scriptPath) {
|
|||
}
|
||||
|
||||
function buildAll() {
|
||||
const files = fs.readdirSync(srcDir);
|
||||
const files = fs.readdirSync(srcDir, {
|
||||
recursive: true,
|
||||
});
|
||||
files.forEach((file) => {
|
||||
console.log(file);
|
||||
if (file.endsWith(".user.js")) {
|
||||
buildScript(path.join(srcDir, file));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue