Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added match argument for custom git-describe matcher #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ With that setup the file is updated when `npm start` and `npm build` are run.

## Command arguments

| Argument | Meaning | Default |
|---|---|---|
| --root | root directory where your package.json is located | . |
| --file | relative location of the output file (based on the root directory) | ./src/_versions.ts | false |
| --git | relative location of the folder containing the .git folder (based on the root directory) | . |
| --set-version | Set this to override the value of the version string fetched from package.json (set in `version` property) | |
| Argument | Meaning | Default |
|---------------|------------------------------------------------------------------------------------------------------------|--------------------|
| --root | root directory where your package.json is located | . |
| --file | relative location of the output file (based on the root directory) | ./src/_versions.ts | false |
| --git | relative location of the folder containing the .git folder (based on the root directory) | . |
| --set-version | Set this to override the value of the version string fetched from package.json (set in `version` property) | |
| --match | Set this to override the git-describe default tag-matcher | v[0-9]* |

## Receiving the versions

Expand Down
8 changes: 7 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,15 @@ if (fs.existsSync(path.join(gitFolder, '.git'))) {
}

if (enableGit) {

let match = 'v[0-9]*';
if (argv.hasOwnProperty('match')) {
match = argv['match']
console.log('[TsAppVersion] Using ' + match + ' as a git-describe tag-matcher.');
}
const git = require('git-describe');
try {
const info = git.gitDescribeSync(gitFolder, { longSemver: true });
const info = git.gitDescribeSync(gitFolder, { longSemver: true, match });
let versionWithHash = appVersion;
if (info.hasOwnProperty('hash')) {
versionWithHash = versionWithHash + '-' + info.hash;
Expand Down
Loading