-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test to make sure configHash option is working
- Loading branch information
Showing
10 changed files
with
133 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function(n) { | ||
return n + (n > 0 ? n - 2 : 0); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var fib = require('./fib'); | ||
|
||
console.log(fib(3)); |
24 changes: 24 additions & 0 deletions
24
tests/fixtures/hard-source-confighash-dir/webpack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
var fs = require('fs'); | ||
|
||
var HardSourceWebpackPlugin = require('../../..'); | ||
|
||
module.exports = { | ||
context: __dirname, | ||
entry: './index.js', | ||
output: { | ||
path: __dirname + '/tmp', | ||
filename: 'main.js', | ||
}, | ||
plugins: [ | ||
new HardSourceWebpackPlugin({ | ||
cacheDirectory: 'cache/[confighash]', | ||
recordsPath: 'cache/[confighash]/records.json', | ||
configHash: function(config) { | ||
return fs.readFileSync(__dirname + '/config-hash', 'utf8'); | ||
}, | ||
environmentPaths: { | ||
root: __dirname + '/../../..', | ||
}, | ||
}), | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function(n) { | ||
return n + (n > 0 ? n - 2 : 0); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var fib = require('./fib'); | ||
|
||
console.log(fib(3)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
var fs = require('fs'); | ||
|
||
var HardSourceWebpackPlugin = require('../../..'); | ||
|
||
module.exports = { | ||
context: __dirname, | ||
entry: './index.js', | ||
output: { | ||
path: __dirname + '/tmp', | ||
filename: 'main.js', | ||
}, | ||
plugins: [ | ||
new HardSourceWebpackPlugin({ | ||
cacheDirectory: 'cache', | ||
recordsPath: 'cache/records.json', | ||
configHash: function(config) { | ||
return fs.readFileSync(__dirname + '/config-hash', 'utf8'); | ||
}, | ||
environmentPaths: { | ||
root: __dirname + '/../../..', | ||
}, | ||
}), | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
var fs = require('fs'); | ||
|
||
var expect = require('chai').expect; | ||
|
||
var itCompilesChange = require('./util').itCompilesChange; | ||
|
||
describe('hard-source features', function() { | ||
|
||
itCompilesChange('hard-source-confighash', { | ||
'config-hash': 'a', | ||
'fib.js': [ | ||
'module.exports = function(n) {', | ||
' return n + (n > 0 ? n - 1 : 0);', | ||
'};', | ||
].join('\n'), | ||
'fib/index.js': null, | ||
}, { | ||
'config-hash': 'b', | ||
'fib.js': null, | ||
'fib/index.js': [ | ||
'module.exports = function(n) {', | ||
' return n + (n > 0 ? n - 2 : 0);', | ||
'};', | ||
].join('\n'), | ||
}, function(output) { | ||
expect(fs.readdirSync(__dirname + '/fixtures/hard-source-confighash/tmp/cache')) | ||
.to.have.length(6); | ||
}); | ||
|
||
itCompilesChange('hard-source-confighash-dir', { | ||
'config-hash': 'a', | ||
'fib.js': [ | ||
'module.exports = function(n) {', | ||
' return n + (n > 0 ? n - 1 : 0);', | ||
'};', | ||
].join('\n'), | ||
'fib/index.js': null, | ||
}, { | ||
'config-hash': 'b', | ||
'fib.js': null, | ||
'fib/index.js': [ | ||
'module.exports = function(n) {', | ||
' return n + (n > 0 ? n - 2 : 0);', | ||
'};', | ||
].join('\n'), | ||
}, function(output) { | ||
expect(fs.readdirSync(__dirname + '/fixtures/hard-source-confighash-dir/tmp/cache')) | ||
.to.have.length(2); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters