fix
This commit is contained in:
parent
cd856a75f3
commit
72c9212d9e
|
|
@ -12,6 +12,10 @@ import { config } from "./utils/config";
|
|||
import { g } from "./utils/global";
|
||||
import { createLogger } from "./utils/logger";
|
||||
|
||||
if (process.argv[process.argv.length - 1] === "skip_types") {
|
||||
g.skip_build_types = true;
|
||||
}
|
||||
|
||||
let db_env: any = {};
|
||||
try {
|
||||
db_env = parseEnv(await Bun.file(dir("app/db/.env")).text());
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ if (process.env.DATABASE_URL) {
|
|||
}
|
||||
}
|
||||
|
||||
const startMain = () => {
|
||||
const startMain = (argv?: string) => {
|
||||
return Bun.spawn({
|
||||
cmd: ["bun", "run", "pkgs/index.ts"],
|
||||
cmd: ["bun", "run", "pkgs/index.ts", argv].filter((e) => e) as string[],
|
||||
cwd: process.cwd(),
|
||||
stdout: "inherit",
|
||||
stderr: "inherit",
|
||||
|
|
@ -49,7 +49,7 @@ const startMain = () => {
|
|||
setTimeout(() => {
|
||||
subprocess.kill();
|
||||
}, 5000);
|
||||
main.process = startMain();
|
||||
main.process = startMain("skip_types");
|
||||
}
|
||||
},
|
||||
onExit(subprocess, exitCode, signalCode, error) {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { dir } from "../utils/dir";
|
|||
import { g } from "../utils/global";
|
||||
|
||||
export const prepareAPITypes = async () => {
|
||||
if (!g.skip_build_types) {
|
||||
const out: string[] = [];
|
||||
for (const [k, v] of Object.entries(g.api)) {
|
||||
const name = k.substring(0, k.length - 3).replace(/\W/gi, "_");
|
||||
|
|
@ -15,7 +16,10 @@ export const prepareAPITypes = async () => {
|
|||
|
||||
if (!(await existsAsync(dir(p.path)))) {
|
||||
p.path = `"pkgs/api/${v.path}"`;
|
||||
p.handler = `"../../pkgs/api/${v.path.substring(0, v.path.length - 3)}"`;
|
||||
p.handler = `"../../pkgs/api/${v.path.substring(
|
||||
0,
|
||||
v.path.length - 3
|
||||
)}"`;
|
||||
}
|
||||
|
||||
out.push(`\
|
||||
|
|
@ -52,6 +56,7 @@ export const ${name} = {
|
|||
res = res.replace(`db: PrismaClient;`, "");
|
||||
await Bun.write(targetFile, res);
|
||||
}
|
||||
}
|
||||
|
||||
await getContent("load.js.dev");
|
||||
console.log("API Loaded");
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ export const g = global as unknown as {
|
|||
log: Logger;
|
||||
firebaseInit: boolean;
|
||||
firebase: admin.app.App;
|
||||
skip_build_types: boolean;
|
||||
main: {
|
||||
process: null | Subprocess;
|
||||
restart: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue