1 | #! /usr/bin/env node
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | import * as fs from "fs-extra";
|
9 | import * as path from "path";
|
10 | import { obtainGitInfo } from "../lib/internal/env/gitInfo";
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | async function main(): Promise<never> {
|
18 | try {
|
19 | const cwd = process.cwd();
|
20 | const gitInfoName = "git-info.json";
|
21 | const gitInfoPath = path.join(cwd, gitInfoName);
|
22 | const gitInfo = await obtainGitInfo(cwd);
|
23 | await fs.writeJson(gitInfoPath, gitInfo, { spaces: 2, encoding: "utf8" });
|
24 | console.info(`Successfully wrote git information to '${gitInfoPath}'`);
|
25 | process.exit(0);
|
26 | } catch (e) {
|
27 | console.error(`Failed to generate Git information: ${e.message}`);
|
28 | process.exit(1);
|
29 | }
|
30 | throw new Error("Should never get here, process.exit() called above");
|
31 | }
|
32 |
|
33 | main()
|
34 | .catch((err: Error) => {
|
35 | console.error(`Unhandled exception: ${err.message}`);
|
36 | process.exit(101);
|
37 | });
|