Skip to content

Commit

Permalink
Adds flag --force-git to force Git detection
Browse files Browse the repository at this point in the history
  • Loading branch information
saitho committed Jan 2, 2018
1 parent 65a0c6b commit 7287c67
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ With that setup the file is updated when `npm start` and `npm run-script build`

The script generates a TypeScript file at the location: `./src/_versions.ts`.
You can change that by passing the option *--file*, e.g. `node ./node_modules/ng-appversion/index.js --file=src/config/version.ts`.
If your .git folder is not in the same folder as your node_modules folder, automatic detection won't work. In that case you can add *--force-git* to force detection.

You'll be able to import the values just like any other package:
```
Expand Down
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,16 @@ const versionFilePath = path.join(versionFile);

let src = 'export const version = \'' + appVersion + '\';\n';

if (fs.existsSync(gitFolder)) {
let enableGit = false;
if (argv.hasOwnProperty('force-git')) {
enableGit = true;
console.log('[NgAppVersion] Git repository forced. Getting current commit information.');
} else if (fs.existsSync(gitFolder)) {
enableGit = true;
console.log('[NgAppVersion] Git repository detected. Getting current commit information.');
}

if (enableGit) {
const git = require('git-describe');
try {
const info = git.gitDescribeSync({ longSemver: true });
Expand Down

0 comments on commit 7287c67

Please sign in to comment.