#gulp-fileinfo
Package | gulp-fileinfo |
Description | Reads the names of the vynil files that are coming through the pipe or any other properties that you want (See the Vinyl docs for a full list of properties). You can either show the file list in the console or get an array with the list of files. |
Node Version | >= 0.10 |
var gulp = require('gulp');
var fileinfo = require('gulp-fileinfo');
gulp.task('default', function() {
return gulp
.src('./lib/*.js')
.pipe(fileinfo());
});
This will output to the console the list of files coming through the pipe.
If you need to get the list of files in an array, you can pass a callback function as part of the options, that function will receive the list of files in an array as a paramenter
var fileinfo = require('gulp-fileinfo');
gulp.task('default', function() {
var doSomethingWithTheFilesList = function (filesList){
//do something with the filesList array here
}
gulp
.src('./lib/*.js')
.pipe(fileinfo({ callback: doSomethingWithTheFilesList }));
});
The fileList variable will be an array of strings containing the name of the files in the pipe.
By default, the gulp only reads the relative
property of the files. If you want something different, you can use:
Specifies the name of the property you want to read (instead of reading the relative
property) from the files in the pipe, like this:
{"properties": "path"}
If you want to read more than one properties at once, you need to set the properties
property as an array of all the properties you want to read.
{"properties": ["relative","path","basename"]}
When the properties
value is an array, the filesList array will contain objects (instead of strings), for instance:
[{"relative":"index.js",
"path":"path/to/index.js",
"basename":"" }]
You can get a full list of the Vinyl files properties here: https://github.com/gulpjs/vinyl
Callback function that will be invoked once all the files have been read. It receives as a parameter the filesList array containing all the info read from the files in the pipe.