delete-lines-using-string

1.1.4 • Public • Published

delete-lines-using-string

Removes lines before/after a string match.

Methods

// includeSearchLength allows you to either include the search string itself in the deletion process or not.

removeBefore(search,includeSearchLength)           // Removes all lines before the search string
removeAfter(search,includeSearchLength)            // Removes all lines after the search string
var gulp = require('gulp'),
    rename = require('gulp-rename'),
    deleteLinesUsingString = require('delete-lines-using-string');

gulp.task('deleteLinesUsingString:removeBefore', function(){
    gulp.src('src/example.html')
        .pipe(deleteLinesUsingString.removeBefore('<!-- DELETION POINT -->', true))
        .pipe(rename('beforeTrue.html'))
        .pipe(gulp.dest('build'));
});

gulp.task('deleteLinesUsingString:removeAfter', function(){
    gulp.src('src/example.html')
        .pipe(deleteLinesUsingString.removeAfter('<!-- DELETION POINT -->', true))
        .pipe(rename('afterTrue.html'))
        .pipe(gulp.dest('build'));
});

gulp.task('deleteLinesUsingString:removeBeforeFalse', function(){
    gulp.src('src/example.html')
        .pipe(deleteLinesUsingString.removeBefore('<!-- DELETION POINT -->', false))
        .pipe(rename('beforeFalse.html'))
        .pipe(gulp.dest('build'));
});

gulp.task('deleteLinesUsingString:removeAfterFalse', function(){
    gulp.src('src/example.html')
        .pipe(deleteLinesUsingString.removeAfter('<!-- DELETION POINT -->', false))
        .pipe(rename('afterFalse.html'))
        .pipe(gulp.dest('build'));
});

gulp.task('default', [
    'deleteLinesUsingString:removeBefore',
    'deleteLinesUsingString:removeAfter',
    'deleteLinesUsingString:removeBeforeFalse',
    'deleteLinesUsingString:removeAfterFalse'
]);

Changes

v1.0.0 - 2018-08-22

  • Initial Commit

Special Thanks

Major props to Michael Hazell for developing gulp-inject-string which a lot of this was repurposed from. You can find gulp-inject-string here: https://github.com/Schmicko/gulp-inject-string

Package Sidebar

Install

npm i delete-lines-using-string

Weekly Downloads

1

Version

1.1.4

License

MIT

Unpacked Size

8.34 kB

Total Files

6

Last publish

Collaborators

  • michaell31