Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
141
rated 0 times [  143] [ 2]  / answers: 1 / hits: 33597  / 9 Years ago, sun, august 2, 2015, 12:00:00

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.


More From » gulp

 Answers
9

According to the gulp documentation on gulp.src (https://github.com/gulpjs/gulp/blob/master/docs/API.md#gulpsrcglobs-options)



gulp.src(globs[, options])


Emits files matching provided glob or an array of globs. Returns a
stream of Vinyl files that can be piped to plugins.


gulp.src('client/templates/*.jade')
.pipe(jade())
.pipe(minify())
.pipe(gulp.dest('build/minified_templates'));

glob refers to node-glob syntax or it can be a direct file path.


globs


Type: String or Array


Glob or array of globs to read.


options


Type: Object


Options to pass to node-glob through glob-stream.


gulp adds some additional options in addition to the options supported
by node-glob and glob-stream



So it seems you need to look in further on this. Otherwise this maybe helpful Get the current file name in gulp.src()


[#65571] Thursday, July 30, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bretd

Total Points: 6
Total Questions: 100
Total Answers: 97

Location: England
Member since Sun, May 21, 2023
1 Year ago
bretd questions
Sun, Jul 12, 20, 00:00, 4 Years ago
Sun, May 24, 20, 00:00, 4 Years ago
Mon, Jan 6, 20, 00:00, 5 Years ago
Mon, Jan 6, 20, 00:00, 5 Years ago
;