mirror of
https://github.com/spacebarchat/server.git
synced 2026-06-04 08:41:36 +00:00
restructure to single project
This commit is contained in:
committed by
TheArcaneBrony
parent
5abd6bb7e0
commit
5e86d7ab9c
@@ -0,0 +1,34 @@
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const { execIn, getLines, parts } = require('./utils');
|
||||
|
||||
if (!process.argv[2] || !fs.existsSync(process.argv[2])) {
|
||||
console.log("Please pass a directory that exists!");
|
||||
process.exit(1);
|
||||
}
|
||||
console.log(`// ${process.argv[2]}/index.ts`)
|
||||
const recurse = process.argv.includes("--recursive")
|
||||
|
||||
const files = fs.readdirSync(process.argv[2]).filter(x => x.endsWith('.ts') && x != 'index.ts');
|
||||
|
||||
let output = '';
|
||||
|
||||
files.forEach(x => output += `export * from "./${x.replaceAll('.ts','')}";\n`)
|
||||
|
||||
const dirs = fs.readdirSync(process.argv[2]).filter(x => {
|
||||
try {
|
||||
fs.readdirSync(path.join(process.argv[2], x));
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
dirs.forEach(x => {
|
||||
output += `export * from "./${x}/index";\n`
|
||||
})
|
||||
console.log(output);
|
||||
fs.writeFileSync(path.join(process.argv[2], "index.ts"), output)
|
||||
|
||||
dirs.forEach(x => {
|
||||
if(recurse) console.log(execIn([process.argv[0], process.argv[1], `"${path.join(process.argv[2], x)}"`, "--recursive"].join(' '), process.cwd()))
|
||||
})
|
||||
Reference in New Issue
Block a user