UNPKG

1.88 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("../internal/env/gitInfo");
15const logger_1 = require("../internal/util/logger");
16logger_1.LoggingConfig.format = "cli";
17/**
18 * Generate git-info.json for automation client.
19 */
20function main() {
21 return __awaiter(this, void 0, void 0, function* () {
22 try {
23 const cwd = process.cwd();
24 const gitInfoName = "git-info.json";
25 const gitInfoPath = path.join(cwd, gitInfoName);
26 const gitInfo = yield gitInfo_1.obtainGitInfo(cwd);
27 yield fs.writeJson(gitInfoPath, gitInfo, { spaces: 2, encoding: "utf8" });
28 logger_1.logger.info(`Successfully wrote git information to '${gitInfoPath}'`);
29 process.exit(0);
30 }
31 catch (e) {
32 logger_1.logger.error(`Failed to generate Git information: ${e.message}`);
33 process.exit(1);
34 }
35 throw new Error("Should never get here, process.exit() called above");
36 });
37}
38main()
39 .catch((err) => {
40 logger_1.logger.error(`Unhandled exception: ${err.message}`);
41 process.exit(101);
42});
43//# sourceMappingURL=git-info.js.map
\No newline at end of file