I'm trying to create an index of all file(path)s within a given folder. So far I worked with gulp.src(filePath)
to achieve that. According to this blog post, it should work:
gulp.src(files) is a string or array containing the file(s) / file paths.
My current code:
gulp.task("createFileIndex", function(){
var index = gulp.src(['./content/**/*.*']);
console.log("INDEX:", index[0]);
});
By outputing the returned values of gulp.src()
with index[0]
I get undefined
and the whole index
outputs only a large dictionary without any filepaths.
The current solution is:
var gulp = require('gulp');
var debug = require('gulp-debug');
gulp.src(sources)
.pipe(debug());
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"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With