carstenschaefer / gulp-delete-lines Goto Github PK
View Code? Open in Web Editor NEWA gulp plugin that will remove all lines that matches one of the given regex filters.
License: MIT License
A gulp plugin that will remove all lines that matches one of the given regex filters.
License: MIT License
Hey,
it seems like your code has a major bug producing douplicates of valid lines of more than one filter is set:
for (_j = 0; _j < opt.filters.length; _j++) {
if (! lines[_i].match(opt.filters[_j])) {
newLines.push(lines[_i]);
}
}
In the inner for loop you have to check if the line was already added or if better would be to add it in the first place and remove it if one of the filters match.
If you don't do this the line will be added for every filter that doesn't match.
Greetz
David
https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
remove gulp-util using the following API replacements:
gutil.File => https://www.npmjs.com/package/vinyl
gutil.replaceExtension => The .extname property on Vinyl objects or https://www.npmjs.com/package/replace-ext
gutil.colors => https://www.npmjs.com/package/ansi-colors
gutil.date => https://www.npmjs.com/package/date-format
gutil.log => https://www.npmjs.com/package/fancy-log
gutil.template => https://www.npmjs.com/package/lodash.template
gutil.env => https://www.npmjs.com/package/minimist
gutil.beep => https://www.npmjs.com/package/beeper
gutil.noop => https://www.npmjs.com/package/through2
gutil.isStream => Use the .isStream() method on Vinyl objects
gutil.isBuffer => Use the .isBuffer() method on Vinyl objects
gutil.isNull => Use the .isNull() method on Vinyl objects
gutil.linefeed => Use the string '\n' in your code
gutil.combine => https://www.npmjs.com/package/multipipe
gutil.buffer => https://www.npmjs.com/package/list-stream
gutil.PluginError => https://www.npmjs.com/package/plugin-error
For example, is there an easy way to remove the last 10 lines from a file?
Hello,
Below is a code of how I've currently setup this function. For some reason on compilation the lines aren't being removed.
// ...
.pipe(deleteLines({
'filters': [
/<base\s+href=["']/i,
/<script\s+src=["']https:\/\/ajax\.googleapis\.com\/ajax\/libs\/jquery\/1\.12\.2\/jquery\.min\.js["']/i
]
}))
// ...
However, when I reduce the array to 1 item like below, it works.
// ...
.pipe(deleteLines({
'filters': [
/<base\s+href=["']/i
]
}))
// ...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.