Answer the question
In order to leave comments, you need to log in
How to properly extract text using GULP?
You need to extract the text from the files and glue the extracted text into one file. Further, I want to use this file in casper.js, but this is not relevant yet.
I watched a few videos about gulp and I really liked it. I started to cut, but it turns out somehow scary:
gulp.task('urlfind:find', function () {
return gulp.src('modules/*.class.php')
.pipe(find(/@url.(.+)+/g))
.pipe(gulp.dest('urlfind'));
})
gulp.task('urlfind:concat',['urlfind:find'], function () {
return gulp.src('urlfind/*.class.php')
.pipe(concat('urls.txt',{newLine: '\r\n'}))
.pipe(gulp.dest(''));
})
gulp.task('urlfind:clean',['urlfind:concat'], function () {
return gulp.src('urlfind/*.class.php', {read: false})
.pipe(clean());
})
gulp.task('urlstart', function () {
gulp.start('urlfind:find', 'urlfind:concat', 'urlfind:clean');
})
Answer the question
In order to leave comments, you need to log in
no need to save files to disk after each pipe, they can be chained
gulp.task('urlfind', function () {
return gulp.src('modules/*.class.php')
.pipe(find(/@url.(.+)+/g))
.pipe(concat('urls.txt',{newLine: '\r\n'}))
.pipe(gulp.dest(''));
})
Don't forget to install the package.
And a variable. "find" is not taken from anywhere.
Sources can be specified in an array
gulp.src(['modules/*.class.php', 'urlfind/*.class.php', 'urlfind/*.class.php'])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question