summary refs log tree commit diff
path: root/scripts/gen_index.js
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/gen_index.js')
-rw-r--r--scripts/gen_index.js47
1 files changed, 25 insertions, 22 deletions
diff --git a/scripts/gen_index.js b/scripts/gen_index.js
index 71c64a9f..8a3c7eb8 100644
--- a/scripts/gen_index.js
+++ b/scripts/gen_index.js
@@ -1,34 +1,37 @@
 const path = require("path");
 const fs = require("fs");
-const { execIn, getLines, parts } = require('./utils');
+const { execIn, getLines } = require("./utils");
 
 if (!process.argv[2] || !fs.existsSync(process.argv[2])) {
-    console.log("Please pass a directory that exists!");
-    process.exit(1);
+	console.log("Please pass a directory that exists!");
+	process.exit(1);
 }
-console.log(`// ${process.argv[2]}/index.ts`)
-const recurse = process.argv.includes("--recursive")
+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');
+const files = fs.readdirSync(process.argv[2]).filter((x) => x.endsWith(".ts") && x != "index.ts");
 
-let output = '';
+let output = "";
 
-files.forEach(x => output += `export * from "./${x.replaceAll('.ts','')}";\n`)
+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; 
-    }
+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`;
 });
-dirs.forEach(x => {
-    output += `export * from "./${x}/index";\n`
-})
 console.log(output);
-fs.writeFileSync(path.join(process.argv[2], "index.ts"), 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
+dirs.forEach((x) => {
+	if (recurse)
+		console.log(
+			execIn([process.argv[0], process.argv[1], `"${path.join(process.argv[2], x)}"`, "--recursive"].join(" "), process.cwd())
+		);
+});