qfiles

1.0.1 • Public • Published

qfiles

Helpers for handling files with Node.js (without dependency).

Install

npm install qfiles

or with Yarn:

yarn add qfiles

Usage

See the source code for the JS doc.

requireAll

some-dir/index.js

let {requireAll} = require('qfiles');

// load all files of the current directory
requireAll(__dirname);

You can load all modules and populate to an object:

some-dir/index.js

let {requireAll} = require('qfiles');
let obj = {};

requireAll(__dirname, obj);

// print each modules values: {moduleName: 'exported value', foo: 'bar', ...}
console.log(obj);

requireToObj

some-dir/index.js

let {requireToObj} = require('qfiles');
let obj = {};

requireToObj(obj, fs.readdirSync(__dirname), './');

// print each modules values: {moduleName: 'exported value', foo: 'bar', ...}
console.log(obj);

requireFiles

let {requireFiles} = require('qfiles');

requireFiles(fs.readdirSync(__dirname), './');

Unit tests

qfiles is unit tested with Mocha and Unit.js.

You can git clone qfiles project and run the tests:

yarn test

or

npm test

LICENSE

MIT (c) 2014, Nicolas Tallefourtane.

Author

Nicolas Tallefourtane - Nicolab.net
Nicolas Talle
Make a donation via Paypal

Package Sidebar

Install

npm i qfiles

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

5.27 kB

Total Files

4

Last publish

Collaborators

  • nicolab