Skip to content

Commit 26fce6c

Browse files
authored
Merge pull request #30 from pirelenito/node-compatibility
Match wepack's engine definitions for Node compatibility
2 parents bc9929b + 8ee316e commit 26fce6c

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
language: node_js
22
node_js:
3+
- "6.11.5"
34
- "8"
45
- "9"
56
# send builds to the container-based infrastructure

lib/build-file.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var runGitCommand = require('./helpers/run-git-command')
22

3-
module.exports = function buildFile (compiler, gitWorkTree, command, replacePattern, asset) {
3+
module.exports = ({ compiler, gitWorkTree, command, replacePattern, asset }) => {
44
var data = ''
55

66
compiler.hooks.compilation.tap('compilation', (compilation) => {

lib/index.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,30 @@ function GitRevisionPlugin (options) {
2727
}
2828

2929
GitRevisionPlugin.prototype.apply = function (compiler) {
30-
buildFile(
31-
compiler,
32-
this.gitWorkTree,
33-
this.commithashCommand,
34-
/\[git-revision-hash\]/gi,
35-
'COMMITHASH'
36-
)
30+
buildFile({
31+
compiler: compiler,
32+
gitWorkTree: this.gitWorkTree,
33+
command: this.commithashCommand,
34+
replacePattern: /\[git-revision-hash\]/gi,
35+
asset: 'COMMITHASH'
36+
})
3737

38-
buildFile(
39-
compiler,
40-
this.gitWorkTree,
41-
this.versionCommand,
42-
/\[git-revision-version\]/gi,
43-
'VERSION'
44-
)
38+
buildFile({
39+
compiler: compiler,
40+
gitWorkTree: this.gitWorkTree,
41+
command: this.versionCommand,
42+
replacePattern: /\[git-revision-version\]/gi,
43+
asset: 'VERSION'
44+
})
4545

4646
if (this.createBranchFile) {
47-
buildFile(
48-
compiler,
49-
this.gitWorkTree,
50-
this.branchCommand,
51-
/\[git-revision-branch\]/gi,
52-
'BRANCH'
53-
)
47+
buildFile({
48+
compiler: compiler,
49+
gitWorkTree: this.gitWorkTree,
50+
command: this.branchCommand,
51+
replacePattern: /\[git-revision-branch\]/gi,
52+
asset: 'BRANCH'
53+
})
5454
}
5555
}
5656

lib/index.spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ describe('git-revision-webpack-plugin (unit)', function () {
1717
}).apply()
1818

1919
var commithashCall = buildFile.args.find(function (calls) {
20-
return calls[4] === 'COMMITHASH'
20+
return calls[0].asset === 'COMMITHASH'
2121
})
2222

23-
expect(commithashCall[2]).to.eql('custom commithash command')
23+
expect(commithashCall[0].command).to.eql('custom commithash command')
2424
})
2525

2626
it('should run the custom git command on .commithash', function () {
@@ -55,10 +55,10 @@ describe('git-revision-webpack-plugin (unit)', function () {
5555
}).apply()
5656

5757
var commithashCall = buildFile.args.find(function (calls) {
58-
return calls[4] === 'VERSION'
58+
return calls[0].asset === 'VERSION'
5959
})
6060

61-
expect(commithashCall[2]).to.eql('custom version command')
61+
expect(commithashCall[0].command).to.eql('custom version command')
6262
})
6363

6464
it('should run the custom git command on .version', function () {
@@ -84,10 +84,10 @@ describe('git-revision-webpack-plugin (unit)', function () {
8484
}).apply()
8585

8686
var branchCall = buildFile.args.find(function (calls) {
87-
return calls[4] === 'BRANCH'
87+
return calls[0].asset === 'BRANCH'
8888
})
8989

90-
expect(branchCall[2]).to.eql('custom branch command')
90+
expect(branchCall[0].command).to.eql('custom branch command')
9191
})
9292

9393
it('should run the custom git command on .version', function () {

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
"test:unit-watch": "npm run test:unit -- --watch"
1111
},
1212
"engines": {
13-
"node": ">=8.0.0",
14-
"npm": ">=5.0.0"
13+
"node": ">=6.11.5"
1514
},
1615
"files": [
1716
"lib"

0 commit comments

Comments
 (0)