@@ -4,6 +4,7 @@ var runGitCommand = require('./helpers/run-git-command')
4
4
var COMMITHASH_COMMAND = 'rev-parse HEAD'
5
5
var VERSION_COMMAND = 'describe --always'
6
6
var BRANCH_COMMAND = 'rev-parse --abbrev-ref HEAD'
7
+ var LASTCOMMITDATETIME_COMMAND = 'log -1 --format=%cI'
7
8
8
9
function GitRevisionPlugin ( options ) {
9
10
options = options || { }
@@ -21,6 +22,9 @@ function GitRevisionPlugin (options) {
21
22
this . branchCommand = options . branchCommand ||
22
23
BRANCH_COMMAND
23
24
25
+ this . lastCommitDateTimeCommand = options . lastCommitDateTimeCommand ||
26
+ LASTCOMMITDATETIME_COMMAND
27
+
24
28
if ( options . versionCommand && options . lightweightTags ) {
25
29
throw new Error ( 'lightweightTags can\'t be used together versionCommand' )
26
30
}
@@ -43,6 +47,14 @@ GitRevisionPlugin.prototype.apply = function (compiler) {
43
47
asset : 'VERSION'
44
48
} )
45
49
50
+ buildFile ( {
51
+ compiler : compiler ,
52
+ gitWorkTree : this . gitWorkTree ,
53
+ command : this . lastCommitDateTimeCommand ,
54
+ replacePattern : / \[ g i t - r e v i s i o n - l a s t - c o m m i t - d a t e t i m e \] / gi,
55
+ asset : 'LASTCOMMITDATETIME'
56
+ } )
57
+
46
58
if ( this . createBranchFile ) {
47
59
buildFile ( {
48
60
compiler : compiler ,
@@ -75,4 +87,11 @@ GitRevisionPlugin.prototype.branch = function () {
75
87
)
76
88
}
77
89
90
+ GitRevisionPlugin . prototype . lastcommitdatetime = function ( ) {
91
+ return runGitCommand (
92
+ this . gitWorkTree ,
93
+ this . lastCommitDateTimeCommand
94
+ )
95
+ }
96
+
78
97
module . exports = GitRevisionPlugin
0 commit comments