Skip to content

Commit 735f856

Browse files
committed
Refactor lightweight tags to remove duplication 🐞
1 parent 4904db7 commit 735f856

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

lib/index.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ var COMMITHASH_COMMAND = 'rev-parse HEAD'
55
var VERSION_COMMAND = 'describe --always'
66

77
function GitRevisionPlugin (options) {
8-
this.gitWorkTree = options && options.gitWorkTree
9-
this.lightweightTags = options && options.lightweightTags || false
10-
this.commithashCommand = options && options.commithashCommand || COMMITHASH_COMMAND
11-
this.versionCommand = options && options.versionCommand || VERSION_COMMAND
8+
options = options || {}
9+
10+
this.gitWorkTree = options.gitWorkTree
11+
12+
this.commithashCommand = options.commithashCommand ||
13+
COMMITHASH_COMMAND
14+
15+
this.versionCommand = options.versionCommand ||
16+
VERSION_COMMAND + (options.lightweightTags ? ' --tags' : '')
1217
}
1318

1419
GitRevisionPlugin.prototype.apply = function (compiler) {
@@ -21,7 +26,7 @@ GitRevisionPlugin.prototype.apply = function (compiler) {
2126

2227
buildFile(compiler,
2328
this.gitWorkTree,
24-
this.versionCommand + (this.lightweightTags ? ' --tags' : ''),
29+
this.versionCommand,
2530
/\[git-revision-version\]/gi,
2631
'VERSION'
2732
)
@@ -37,7 +42,7 @@ GitRevisionPlugin.prototype.commithash = function () {
3742
GitRevisionPlugin.prototype.version = function () {
3843
return runGitCommand(
3944
this.gitWorkTree,
40-
this.versionCommand + (this.lightweightTags ? ' --tags' : '')
45+
this.versionCommand
4146
)
4247
}
4348

0 commit comments

Comments
 (0)