-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerator.ts
More file actions
34 lines (27 loc) · 962 Bytes
/
generator.ts
File metadata and controls
34 lines (27 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#! /usr/bin/env node
import { existsSync } from "fs";
import { readConfigAndGenerateTypes, createConfigFile } from "./bolt.js";
const args = process.argv.slice(2, process.argv.length);
const action = args[0];
if (["init", "i"].includes(action)) {
console.log("Looking for config file...");
if (existsSync("bolt.toml")) {
console.log("Found! Generating types...");
await readConfigAndGenerateTypes();
} else {
console.log("not found. creating bolt.toml");
createConfigFile();
console.log("update bolt.toml and run `npx bolt g` to generate types");
}
} else if (["generate", "g"].includes(action)) {
console.log("generating types...");
const pathToConfig = args[1] || "bolt.toml";
if (!existsSync(pathToConfig)) {
console.error("config file not found:", pathToConfig);
process.exit(1);
}
await readConfigAndGenerateTypes(pathToConfig);
} else {
console.error("Missing or unknown command");
}
process.exit(0);