-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.mjs
35 lines (27 loc) · 897 Bytes
/
setup.mjs
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
35
/**
* This script runs `npx @convex-dev/auth` to help with setting up
* environment variables for Convex Auth.
*
* You can safely delete it and remove it from package.json scripts.
*/
import fs from "fs";
import { config as loadEnvFile } from "dotenv";
import { spawnSync } from "child_process";
if (!fs.existsSync(".env.local")) {
// Something is off, skip the script.
process.exit(0);
}
const config = {};
loadEnvFile({ path: ".env.local", processEnv: config });
const runOnceWorkflow = process.argv.includes("--once");
if (runOnceWorkflow && config.SETUP_SCRIPT_RAN !== undefined) {
// The script has already ran once, skip.
process.exit(0);
}
const result = spawnSync("npx", ["@convex-dev/auth", "--skip-git-check"], {
stdio: "inherit",
});
if (runOnceWorkflow) {
fs.writeFileSync(".env.local", `\nSETUP_SCRIPT_RAN=1\n`, { flag: "a" });
}
process.exit(result.status);