Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit aa69c9a
Showing
11 changed files
with
4,587 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_style = tab | ||
tab_width = 2 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.{md,yml}] | ||
indent_style = space | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.nyc_output | ||
coverage | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
branches: | ||
except: /^v\d/ | ||
language: node_js | ||
node_js: node | ||
after_script: node_modules/.bin/nyc report --reporter=text-lcov | npx coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ISC License (ISC) | ||
Copyright 2018 Shinnosuke Watanabe | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# vfile-glob | ||
|
||
[![npm version](https://img.shields.io/npm/v/vfile-glob.svg)](https://www.npmjs.com/package/vfile-glob) | ||
[![Build Status](https://travis-ci.org/shinnn/vfile-glob.svg?branch=master)](https://travis-ci.org/shinnn/vfile-glob) | ||
[![Build status](https://ci.appveyor.com/api/projects/status/8jwxugh978gw12it/branch/master?svg=true)](https://ci.appveyor.com/project/ShinnosukeWatanabe/vfile-glob/branch/master) | ||
[![Coverage Status](https://img.shields.io/coveralls/shinnn/vfile-glob.svg)](https://coveralls.io/github/shinnn/vfile-glob) | ||
|
||
Search files with [glob](https://github.com/isaacs/node-glob#glob-primer) pattern and create [VFile](https://github.com/vfile/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: <Buffer ... > | ||
} */ | ||
}, | ||
complete() { | ||
console.log('Glob completed.'); | ||
} | ||
}); | ||
``` | ||
|
||
## Installation | ||
|
||
[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/getting-started/what-is-npm). | ||
|
||
``` | ||
npm install vfile-glob | ||
``` | ||
|
||
## API | ||
|
||
```javascript | ||
const vfileGlob = require('vfile-glob'); | ||
``` | ||
|
||
### vfileGlob(*pattern* [, *options*]) | ||
|
||
*pattern*: `string` (glob pattern) | ||
*options*: `Object` ([`read-glob`](https://github.com/shinnn/node-read-glob) options) or `string` (encoding) | ||
Return: [`Observable`](https://github.com/tc39/proposal-observable#observable) ([zenparsing's implementation](https://github.com/zenparsing/zen-observable)) | ||
|
||
When the `Observable` is [subscribe](https://tc39.github.io/proposal-observable/#observable-prototype-subscribe)d, it starts searching files matching the given glob pattern, create [`VFile`](https://github.com/vfile/vfile#vfileoptions)s from matched files and successively sends them to its [`Observer`](https://github.com/tc39/proposal-observable#observer). | ||
|
||
```javascript | ||
vfileGlob('hi.txt').subscribe(file => { | ||
file.cwd; //=> '/Users/example' | ||
file.path; //=> 'hi.txt', | ||
file.contents; //=> <Buffer 48 69> | ||
}); | ||
|
||
vfileGlob('exmaple/hi.txt', { | ||
cwd: '..', | ||
encoding: 'utf8' | ||
}).subscribe(file => { | ||
file.cwd; //=> '/Users' | ||
file.path; //=> 'example/hi.txt' | ||
file.contents; //=> 'Hi' | ||
}); | ||
``` | ||
|
||
## License | ||
|
||
[ISC License](./LICENSE) © 2018 Shinnosuke Watanabe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
image: Visual Studio 2017 | ||
platform: x64 | ||
shallow_clone: true | ||
skip_tags: true | ||
install: | ||
- ps: Install-Product node Stable x64 | ||
- npm install | ||
build: off | ||
test_script: node test.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
const readGlob = require('read-glob'); | ||
const vfile = require('vfile'); | ||
|
||
function globResultToVfile({contents, cwd, path, stat}) { | ||
return vfile({ | ||
contents, | ||
cwd, | ||
path, | ||
data: stat ? {stat} : {} | ||
}); | ||
} | ||
|
||
module.exports = function vfileGlob(...args) { | ||
return readGlob(...args).map(globResultToVfile); | ||
}; |
Oops, something went wrong.