gulp-replace
Advanced tools
Comparing version 0.5.2 to 0.5.3
30
index.js
@@ -1,14 +0,15 @@ | ||
var es = require('event-stream'); | ||
'use strict'; | ||
var through = require('through2'); | ||
var rs = require('replacestream'); | ||
var stream = require('stream'); | ||
var istextorbinary = require('istextorbinary'); | ||
module.exports = function(search, replacement, options) { | ||
var doReplace = function(file, callback) { | ||
var isRegExp = search instanceof RegExp; | ||
var isStream = file.contents && typeof file.contents.on === 'function' && typeof file.contents.pipe === 'function'; | ||
var isBuffer = file.contents instanceof Buffer; | ||
var doReplace = function(file, enc, callback) { | ||
if (file.isNull()) { | ||
return callback(null, file); | ||
} | ||
function doReplace() { | ||
if (isStream) { | ||
if (file.isStream()) { | ||
file.contents = file.contents.pipe(rs(search, replacement)); | ||
@@ -18,4 +19,4 @@ return callback(null, file); | ||
if (isBuffer) { | ||
if (isRegExp) { | ||
if (file.isBuffer()) { | ||
if (search instanceof RegExp) { | ||
file.contents = new Buffer(String(file.contents).replace(search, replacement)); | ||
@@ -54,3 +55,2 @@ } | ||
callback(null, file); | ||
} | ||
@@ -65,3 +65,3 @@ | ||
if (!result) { | ||
return callback(null, file); | ||
callback(null, file); | ||
} else { | ||
@@ -71,10 +71,10 @@ doReplace(); | ||
}); | ||
return; | ||
} | ||
else { | ||
doReplace(); | ||
} | ||
doReplace(); | ||
}; | ||
return es.map(doReplace); | ||
return through.obj(doReplace); | ||
}; |
{ | ||
"name": "gulp-replace", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "A string replace plugin for gulp", | ||
"main": "index.js", | ||
"dependencies": { | ||
"event-stream": "3.2.1", | ||
"istextorbinary": "1.0.2", | ||
"replacestream": "2.0.0", | ||
"istextorbinary": "1.0.2" | ||
"through2": "0.6.3" | ||
}, | ||
"devDependencies": { | ||
"should": "^4.6.0", | ||
"event-stream": "^3.2.2", | ||
"mocha": "^2.1.0", | ||
"gulp-util": "^3.0.2" | ||
"should": "^5.0.0", | ||
"vinyl": "^0.4.6" | ||
}, | ||
"scripts": { | ||
"test": "./node_modules/.bin/mocha" | ||
"test": "mocha" | ||
}, | ||
@@ -19,0 +19,0 @@ "repository": { |
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
5690
4
61
+ Addedthrough2@0.6.3
+ Addedcore-util-is@1.0.3(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedreadable-stream@1.0.34(transitive)
+ Addedstring_decoder@0.10.31(transitive)
+ Addedthrough2@0.6.3(transitive)
+ Addedxtend@4.0.2(transitive)
- Removedevent-stream@3.2.1
- Removedduplexer@0.1.2(transitive)
- Removedevent-stream@3.2.1(transitive)
- Removedfrom@0.1.7(transitive)
- Removedmap-stream@0.1.0(transitive)
- Removedpause-stream@0.0.11(transitive)
- Removedsplit@0.2.10(transitive)
- Removedstream-combiner@0.0.4(transitive)