Search files with glob pattern and create VFile objects from them
npm install vfile-glob



Search files with glob pattern and create VFile objects from them
``javascript
const vfileGlob = require('vfile-glob');
vfileGlob('index.*').subscribe({
start() {
console.log('Glob started.');
},
next(file) {
file;
/*=> VFile {
data: {},
messages: [],
history: ['index.js'],
cwd: '/Users/shinnn/github/vfile-glob',
contents:
} */
},
complete() {
console.log('Glob completed.');
}
});
`
``
npm install vfile-glob
`javascript`
const vfileGlob = require('vfile-glob');
pattern: string (glob pattern) Object
options: (read-glob options) or string (encoding) Observable
Return: (zenparsing's implementation)
When the Observable is subscribed, it starts searching files matching the given glob pattern, create VFiles from matched files and successively sends them to its Observer.
`javascript
vfileGlob('hi.txt').subscribe(file => {
file.cwd; //=> '/Users/example'
file.path; //=> 'hi.txt',
file.contents; //=>
});
vfileGlob('exmaple/hi.txt', {
cwd: '..',
encoding: 'utf8'
}).subscribe(file => {
file.cwd; //=> '/Users'
file.path; //=> 'example/hi.txt'
file.contents; //=> 'Hi'
});
``
ISC License © 2018 Shinnosuke Watanabe