Skip to content

Instantly share code, notes, and snippets.

@amcdnl
Created February 13, 2018 16:28
Show Gist options
  • Select an option

  • Save amcdnl/facf888edd18b9baa552735129d4c23d to your computer and use it in GitHub Desktop.

Select an option

Save amcdnl/facf888edd18b9baa552735129d4c23d to your computer and use it in GitHub Desktop.

Revisions

  1. amcdnl created this gist Feb 13, 2018.
    21 changes: 21 additions & 0 deletions version.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    const { gitDescribeSync } = require('git-describe');
    const { version } = require('../package.json');
    const { resolve, relative } = require('path');
    const { writeFileSync } = require('fs-extra');

    const gitInfo = gitDescribeSync({
    dirtyMark: false,
    dirtySemver: false
    });

    gitInfo.version = version;

    const file = resolve(__dirname, '..', 'src', 'environments', 'version.ts');
    writeFileSync(file,
    `// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
    /* tslint:disable */
    export const VERSION = ${JSON.stringify(gitInfo, null, 4)};
    /* tslint:enable */
    `, { encoding: 'utf-8' });

    console.log(`Wrote version info ${gitInfo.raw} to ${relative(resolve(__dirname, '..'), file)}`);