diff --git a/index.js b/index.js index 28eaa9f..16538de 100644 --- a/index.js +++ b/index.js @@ -39,10 +39,10 @@ module.exports = function (file, opts) { if (typeof opts.replace[i].from === "undefined") throw new Error("configuration entry \"replace[" + i + "].from\" not defined"); if (!(typeof opts.replace[i].from === "object" && opts.replace[i].from instanceof RegExp)) - opts.replace[i].from = new RegExp(opts.replace[i].from); + opts.replace[i].from = new RegExp(opts.replace[i].from, 'g'); if (typeof opts.replace[i].to === "undefined") throw new Error("configuration entry \"replace[" + i + "].to\" not defined"); - if (!(typeof opts.replace[i].to === "string")) + if (!(typeof opts.replace[i].to === "string" || opts.replace[i].to instanceof Function)) opts.replace[i].to = String(opts.replace[i].to); } diff --git a/package.json b/package.json index 9d29b34..5bc6960 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,6 @@ "homepage": "https://github.com/rse/browserify-replace", "bugs": "https://github.com/rse/browserify-replace/issues", "dependencies": { - "through2": "^1.1.1" + "through2": "^2.0.0" } }