@@ -4,6 +4,7 @@ var runGitCommand = require('./helpers/run-git-command')
44var COMMITHASH_COMMAND = 'rev-parse HEAD'
55var VERSION_COMMAND = 'describe --always'
66var BRANCH_COMMAND = 'rev-parse --abbrev-ref HEAD'
7+ var LASTCOMMITDATETIME_COMMAND = 'log -1 --format=%cI'
78
89function GitRevisionPlugin ( options ) {
910 options = options || { }
@@ -21,6 +22,9 @@ function GitRevisionPlugin (options) {
2122 this . branchCommand = options . branchCommand ||
2223 BRANCH_COMMAND
2324
25+ this . lastCommitDateTimeCommand = options . lastCommitDateTimeCommand ||
26+ LASTCOMMITDATETIME_COMMAND
27+
2428 if ( options . versionCommand && options . lightweightTags ) {
2529 throw new Error ( 'lightweightTags can\'t be used together versionCommand' )
2630 }
@@ -43,6 +47,14 @@ GitRevisionPlugin.prototype.apply = function (compiler) {
4347 asset : 'VERSION'
4448 } )
4549
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+
4658 if ( this . createBranchFile ) {
4759 buildFile ( {
4860 compiler : compiler ,
@@ -75,4 +87,11 @@ GitRevisionPlugin.prototype.branch = function () {
7587 )
7688}
7789
90+ GitRevisionPlugin . prototype . lastcommitdatetime = function ( ) {
91+ return runGitCommand (
92+ this . gitWorkTree ,
93+ this . lastCommitDateTimeCommand
94+ )
95+ }
96+
7897module . exports = GitRevisionPlugin
0 commit comments