string-replace-webpack-plugin
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -1,2 +0,5 @@ | ||
## v0.1.1 | ||
## v0.1.3 | ||
* Preserve source map after replacement (@rnons) | ||
## v0.1.2 | ||
* Don't save options on the compiler for Webpack 2.2 compatibility (@CntChen) | ||
@@ -3,0 +6,0 @@ |
@@ -8,3 +8,4 @@ /* | ||
module.exports = function(source) { | ||
module.exports = function(source, map) { | ||
var callback = this.async(); | ||
var id = loaderUtils.parseQuery(this.query).id; | ||
@@ -27,4 +28,4 @@ | ||
this.cacheable && this.cacheable(); | ||
return source; | ||
}; | ||
this.cacheable && this.cacheable(); | ||
callback(null, source, map); | ||
}; |
{ | ||
"name": "string-replace-webpack-plugin", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"author": "James Andersen @jandersen78", | ||
@@ -5,0 +5,0 @@ "description": "Replace string tokens in the contents of a file.", |
25
test.js
@@ -6,3 +6,2 @@ /** | ||
var StringReplacePlugin = require("./index.js"); | ||
var mockConfig = { options: {}, emitWarning: console.log }; | ||
@@ -66,4 +65,16 @@ describe('StringReplacePlugin', function(){ | ||
id = null, | ||
query = null; | ||
query = null, | ||
replaced = null; | ||
var callback = function() { | ||
return function(_, source) { | ||
replaced = source; | ||
}; | ||
}; | ||
var mockConfig = { | ||
options: {}, | ||
emitWarning: console.log, | ||
async: callback | ||
}; | ||
beforeEach(function(){ | ||
@@ -89,6 +100,6 @@ // runs before each test in this block | ||
mockConfig.query = query; | ||
var replaced = loader.call(mockConfig, "some string"); | ||
loader.call(mockConfig, "some string"); | ||
assert(replaced === "some string", "doesn't modify when there are no matches"); | ||
replaced = loader.call(mockConfig, "some <!-- @secret stuff --> string"); | ||
loader.call(mockConfig, "some <!-- @secret stuff --> string"); | ||
assert.equal(replaced, "some replaced ==>stuff<== string", "replaces matches"); | ||
@@ -117,9 +128,9 @@ }); | ||
var replaced = loader.call(mockConfig, "some string"); | ||
loader.call(mockConfig, "some string"); | ||
assert(replaced === "some string", "doesn't modify when there are no matches"); | ||
replaced = loader.call(mockConfig, "some <!-- @secret stuff --> string"); | ||
loader.call(mockConfig, "some <!-- @secret stuff --> string"); | ||
assert.equal(replaced, "some replaced ==>stuff<== string", "replaces matches"); | ||
}); | ||
}) | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12786
183