summary refs log tree commit diff
path: root/scripts/gen_index.js
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-15 11:13:21 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-15 11:13:21 +0200
commit1a94fb1208bf0e4c669cad16aff5f57dc0bf7a3c (patch)
tree1035116ddbaacc5fcc5ae250a6592eb88f78f75c /scripts/gen_index.js
parentDo the funny thing (make user->invite cascade delet) (diff)
parentchange dev panel path, we missed this one... (diff)
downloadserver-1a94fb1208bf0e4c669cad16aff5f57dc0bf7a3c.tar.xz
Merge branch 'dev/restructure' into staging
Diffstat (limited to 'scripts/gen_index.js')
-rw-r--r--scripts/gen_index.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/scripts/gen_index.js b/scripts/gen_index.js
new file mode 100644

index 00000000..71c64a9f --- /dev/null +++ b/scripts/gen_index.js
@@ -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())) +}) \ No newline at end of file