pax_global_header00006660000000000000000000000064126020120130014475gustar00rootroot0000000000000052 comment=538e912ef5784029b47d247e2f488a7c426537c9 fs-readdir-recursive-1.0.0/000077500000000000000000000000001260201201300155205ustar00rootroot00000000000000fs-readdir-recursive-1.0.0/.gitignore000066400000000000000000000000701260201201300175050ustar00rootroot00000000000000 .DS_Store* *-link npm-debug.log node_modules coverage fs-readdir-recursive-1.0.0/.travis.yml000066400000000000000000000002721260201201300176320ustar00rootroot00000000000000language: node_js node_js: - "0.10" - "0.12" - "1" - "2" - "3" - "4" script: "npm run-script test-travis" after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls" fs-readdir-recursive-1.0.0/LICENSE000066400000000000000000000021131260201201300165220ustar00rootroot00000000000000 The MIT License (MIT) Copyright (c) 2014 Jonathan Ong me@jongleberry.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. fs-readdir-recursive-1.0.0/README.md000066400000000000000000000037561260201201300170120ustar00rootroot00000000000000# fs.readdirSyncRecursive [![NPM version][npm-image]][npm-url] [![Build status][travis-image]][travis-url] [![Test coverage][coveralls-image]][coveralls-url] [![Dependency Status][david-image]][david-url] [![License][license-image]][license-url] [![Downloads][downloads-image]][downloads-url] [![Gittip][gittip-image]][gittip-url] Read a directory recursively. ## Install ```bash npm install fs-readdir-recursive ``` ## Example ```js var read = require('fs-readdir-recursive') read(__dirname) === [ 'test/test.js', 'index.js', 'LICENSE', 'package.json', 'README.md' ] ``` ## API ### read(root [, filter]) `root` is the directory you wish to scan. `filter` is an optional filter for the files. By default, filter is: ```js function (x) { return x[0] !== '.' } ``` Which basically just ignores `.` files. [npm-image]: https://img.shields.io/npm/v/fs-readdir-recursive.svg?style=flat-square [npm-url]: https://npmjs.org/package/fs-readdir-recursive [github-tag]: http://img.shields.io/github/tag/fs-utils/fs-readdir-recursive.svg?style=flat-square [github-url]: https://github.com/fs-utils/fs-readdir-recursive/tags [travis-image]: https://img.shields.io/travis/fs-utils/fs-readdir-recursive.svg?style=flat-square [travis-url]: https://travis-ci.org/fs-utils/fs-readdir-recursive [coveralls-image]: https://img.shields.io/coveralls/fs-utils/fs-readdir-recursive.svg?style=flat-square [coveralls-url]: https://coveralls.io/r/fs-utils/fs-readdir-recursive [david-image]: http://img.shields.io/david/fs-utils/fs-readdir-recursive.svg?style=flat-square [david-url]: https://david-dm.org/fs-utils/fs-readdir-recursive [license-image]: http://img.shields.io/npm/l/fs-readdir-recursive.svg?style=flat-square [license-url]: LICENSE [downloads-image]: http://img.shields.io/npm/dm/fs-readdir-recursive.svg?style=flat-square [downloads-url]: https://npmjs.org/package/fs-readdir-recursive [gittip-image]: https://img.shields.io/gratipay/jonathanong.svg?style=flat-square [gittip-url]: https://gratipay.com/jonathanong/ fs-readdir-recursive-1.0.0/index.js000066400000000000000000000010461260201201300171660ustar00rootroot00000000000000var fs = require('fs') var path = require('path') module.exports = read function read(root, filter, files, prefix) { prefix = prefix || '' files = files || [] filter = filter || noDotFiles var dir = path.join(root, prefix) if (!fs.existsSync(dir)) return files if (fs.statSync(dir).isDirectory()) fs.readdirSync(dir) .filter(filter) .forEach(function (name) { read(root, filter, files, path.join(prefix, name)) }) else files.push(prefix) return files } function noDotFiles(x) { return x[0] !== '.' } fs-readdir-recursive-1.0.0/package.json000066400000000000000000000013001260201201300200000ustar00rootroot00000000000000{ "name": "fs-readdir-recursive", "description": "Recursively read a directory", "version": "1.0.0", "scripts": { "test": "mocha --reporter spec", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot" }, "devDependencies": { "istanbul": "0", "mocha": "*", "should": "*" }, "author": { "name": "Jonathan Ong", "email": "me@jongleberry.com", "url": "http://jongleberry.com", "twitter": "https://twitter.com/jongleberry" }, "repository": "fs-utils/fs-readdir-recursive", "files": [ "index.js" ], "license": "MIT" } fs-readdir-recursive-1.0.0/test/000077500000000000000000000000001260201201300164775ustar00rootroot00000000000000fs-readdir-recursive-1.0.0/test/.ignore000066400000000000000000000000001260201201300177510ustar00rootroot00000000000000fs-readdir-recursive-1.0.0/test/test.js000066400000000000000000000051301260201201300200130ustar00rootroot00000000000000var fs = require('fs') var path = require('path') var should = require('should') var read = require('../') describe('fs.readdirSyncRecursive()', function () { it('should work in the folder', function () { var files = read(__dirname) files.length.should.equal(1) files[0].should.equal('test.js') }) it('should work at the root with a filter', function () { var files = read(path.join(__dirname, '..'), function (name) { return name[0] !== '.' && name !== 'node_modules' && name !== 'coverage' }) files.length.should.equal(5) files.sort().should.eql([ 'test/test.js', 'index.js', 'LICENSE', 'package.json', 'README.md' ].sort()) }) it('should work with the symlinked file', function () { try { var linkname = __filename + '-link' fs.symlinkSync(__filename, linkname, 'file') var files = read(__dirname).sort() files.length.should.equal(2) files.should.eql(['test.js', 'test.js-link']) } catch (err) { throw err } finally { fs.unlinkSync(linkname) } }) it('should work in the symlinked directory', function () { try { var linkname = __dirname + '-link' fs.symlinkSync(__dirname, linkname, 'dir') var files = read(linkname) files.length.should.equal(1) files[0].should.equal('test.js') } catch (err) { throw err } finally { fs.unlinkSync(linkname) } }) it('should work in the symlinked directory with a filter', function () { try { var linkname = path.join(__dirname, '..') + '-link' fs.symlinkSync(path.join(__dirname, '..'), linkname, 'dir') var files = read(linkname, function (name) { return name[0] !== '.' && name !== 'node_modules' && name !== 'coverage' }) files.length.should.equal(5) files.sort().should.eql([ 'test/test.js', 'index.js', 'LICENSE', 'package.json', 'README.md' ].sort()) } catch (err) { throw err } finally { fs.unlinkSync(linkname) } }) it('should ignore non-exist symlinked inside', function () { try { var linkname = __filename + '-link' var emptyname = __filename + '-empty' fs.writeFileSync(emptyname, 'empty') fs.symlinkSync(emptyname, linkname, 'dir') fs.unlinkSync(emptyname) var files = read(__dirname) files.should.eql(['test.js']) } catch (err) { throw err } finally { fs.unlinkSync(linkname) } }) it('should return empty array', function () { read('non-exist-dir').should.eql([]) }) })