UNPKG

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