forked from projen/projen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprojen.js
executable file
·41 lines (32 loc) · 1.02 KB
/
projen.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
#!/usr/bin/env node
// ~~ Generated by projen
const { existsSync } = require("fs");
const { execSync } = require("child_process");
function execCommand(command) {
try {
execSync(command, { stdio: "inherit" });
} catch (error) {
console.error(`Failed to execute command: ${command}`, error);
process.exit(1);
}
}
const isBuild = existsSync("lib/cli/index.js");
const hasJsii = existsSync("node_modules/.bin/jsii");
const hasTsNode = existsSync("node_modules/.bin/ts-node");
const needsBootstrapping = !isBuild || !hasTsNode;
const installCommand = "yarn install --frozen-lockfile --check-files --non-interactive";
const buildCommand = "npx jsii --silence-warnings=reserved-word --no-fix-peer-dependencies";
function bootstrap() {
console.info("bootstrapping...");
if (!hasTsNode || !hasJsii) {
execCommand(installCommand);
}
if (!isBuild) {
execCommand(buildCommand);
}
}
if (needsBootstrapping) {
bootstrap();
}
const args = process.argv.slice(2).join(" ");
execCommand(`node bin/projen ${args}`);