UNPKG

1.06 kBPlain TextView Raw
1#! /usr/bin/env node
2/*
3 * Copyright © 2018 Atomist, Inc.
4 *
5 * See LICENSE file.
6 */
7
8import * as fs from "fs-extra";
9import * as path from "path";
10import { obtainGitInfo } from "../lib/internal/env/gitInfo";
11
12/* tslint:disable:no-console */
13
14/**
15 * Generate git-info.json for automation client.
16 */
17async 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
33main()
34 .catch((err: Error) => {
35 console.error(`Unhandled exception: ${err.message}`);
36 process.exit(101);
37 });