-
-
Notifications
You must be signed in to change notification settings - Fork 558
/
Copy pathpost-install.js
43 lines (36 loc) · 1.06 KB
/
post-install.js
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
36
37
38
39
40
41
42
43
/* SPDX-FileCopyrightText: 2014-present Kriasoft */
/* SPDX-License-Identifier: MIT */
import { execa } from "execa";
import { EOL } from "node:os";
import { dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { fs } from "zx";
if (process.env.CI === "true") process.exit();
export const rootDir = dirname(dirname(fileURLToPath(import.meta.url)));
process.cwd(rootDir);
// Enable Git hooks
// https://typicode.github.io/husky/
await execa("yarn", ["husky", "install"], { stdio: "inherit" });
// Create environment variable override files
// such as `env/.prod.override.env`.
const envFile = `./.env.local`;
if (!fs.existsSync(envFile)) {
await fs.writeFile(
envFile,
[
`# Environment variables overrides for local development`,
`#`,
`# GOOGLE_CLOUD_CREDENTIALS=xxxxx`,
"# CLOUDFLARE_API_TOKEN=xxxxx",
`# SENDGRID_API_KEY=SG.xxxxx`,
`# PGPASSWORD=xxxxx`,
``,
].join(EOL),
"utf-8",
);
}
try {
await execa("yarn", ["tsc", "--build"], { stdin: "inherit" });
} catch (err) {
console.error(err);
}