Skip to content

Commit

Permalink
New: First implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
yocontra authored and phated committed Feb 16, 2017
0 parents commit f8dbacd
Show file tree
Hide file tree
Showing 10 changed files with 171 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.DS_Store
*.log
node_modules
build
*.node
components
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.DS_Store
*.log
node_modules
build
*.node
components
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: node_js
node_js:
- 0.6
- 0.7
- 0.8
- 0.9
- 0.10
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2013 Fractal <contact@wearefractal.com>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[![Build Status](https://travis-ci.org/wearefractal/glob-stream.png?branch=master)](https://travis-ci.org/wearefractal/glob-stream)

## Information

<table>
<tr>
<td>Package</td><td>glob-stream</td>
</tr>
<tr>
<td>Description</td>
<td>File system globs as a stream</td>
</tr>
<tr>
<td>Node Version</td>
<td>>= 0.4</td>
</tr>
</table>

This is a simple wrapper around node-glob to make it streamy.

## Usage

```javascript
var gs = require('glob-stream');

var stream = gs.create("./files/**/*.coffee", {options - read node-glob docs});

stream.on('data', function(fileName){
// fileName == full path
});
```

## LICENSE

(MIT License)

Copyright (c) 2013 Fractal <contact@wearefractal.com>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require('coffee-script');
module.exports = require('./lib/main');
23 changes: 23 additions & 0 deletions lib/main.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
es = require 'event-stream'
glob = require 'glob'

module.exports =
create: (globb, opt={}) ->
throw new Error "Invalid or missing glob string" unless typeof globb is 'string'

opt.silent ?= true
opt.nonull ?= false

stream = es.pause()

globber = new glob.Glob globb, opt
globber.on 'error', (e) ->
stream.emit 'error', e

globber.on 'end', ->
stream.emit 'end'

globber.on 'match', (filename) ->
stream.emit 'data', filename

return stream
31 changes: 31 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name":"glob-stream",
"description":"File system globs as a stream",
"version":"0.0.0",
"homepage":"http://github.com/wearefractal/glob-stream",
"repository":"git://github.com/wearefractal/glob-stream.git",
"author":"Fractal <contact@wearefractal.com> (http://wearefractal.com/)",
"main":"./index.js",

"dependencies":{
"coffee-script":"*",
"glob":"*",
"event-stream":"*"
},
"devDependencies":{
"mocha":"*",
"should":"*"
},
"scripts":{
"test":"mocha --compilers coffee:coffee-script"
},
"engines":{
"node":">= 0.4.0"
},
"licenses":[
{
"type":"MIT",
"url":"http://github.com/wearefractal/glob-stream/raw/master/LICENSE"
}
]
}
1 change: 1 addition & 0 deletions test/fixtures/test.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this is a test
19 changes: 19 additions & 0 deletions test/main.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
gs = require '../'
should = require 'should'
require 'mocha'

{join} = require 'path'

# TODO: test back-pressure

describe 'glob-stream', ->
describe 'create()', ->
it 'should return a file name stream from a glob', (done) ->
stream = gs.create join __dirname, "./fixtures/*.coffee"
should.exist stream
stream.on 'error', (err) -> throw err
stream.on 'data', (file) ->
should.exist file
String(file).should.equal join __dirname, "./fixtures/test.coffee"

stream.on 'end', -> done()

0 comments on commit f8dbacd

Please sign in to comment.