List all files in array with gulp.src()
The current solution is:
var gulp = require('gulp');
var debug = require('gulp-debug');
gulp.src(sources)
.pipe(debug());
var through = require('through2');
gulp.task('getFileList', function () {
var fileList = [];
gulp.src(['./someFolder/**/*.ext', '!./someFolder/unwantedFolder/**/*'])
.pipe(through.obj(function (file, enc, cb) {
fileList.push(file.path);
cb(null);
}))
.pipe(gulp.dest('./temp/'))
.on ('end', function () {
console.log(fileList);
});
});
As the OP stated in a comment, a simple solution to this problem would be to use fs.readdirSync
instead of gulp.src
:
fs = require("fs");
fs.readdirSync(directoryPath); // ["file1", "file2"]