UNPKG

1.77 kBJavaScriptView Raw
1#! /usr/bin/env node
2"use strict";
3var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4 return new (P || (P = Promise))(function (resolve, reject) {
5 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
8 step((generator = generator.apply(thisArg, _arguments || [])).next());
9 });
10};
11Object.defineProperty(exports, "__esModule", { value: true });
12const fs = require("fs-extra");
13const path = require("path");
14const gitInfo_1 = require("../lib/internal/env/gitInfo");
15/**
16 * Generate git-info.json for automation client.
17 */
18function main() {
19 return __awaiter(this, void 0, void 0, function* () {
20 try {
21 const cwd = process.cwd();
22 const gitInfoName = "git-info.json";
23 const gitInfoPath = path.join(cwd, gitInfoName);
24 const gitInfo = yield gitInfo_1.obtainGitInfo(cwd);
25 yield fs.writeJson(gitInfoPath, gitInfo, { spaces: 2, encoding: "utf8" });
26 console.info(`Successfully wrote git information to '${gitInfoPath}'`);
27 process.exit(0);
28 }
29 catch (e) {
30 console.error(`Failed to generate Git information: ${e.message}`);
31 process.exit(1);
32 }
33 throw new Error("Should never get here, process.exit() called above");
34 });
35}
36main()
37 .catch((err) => {
38 console.error(`Unhandled exception: ${err.message}`);
39 process.exit(101);
40});
41//# sourceMappingURL=git-info.js.map
\No newline at end of file