qfiles
v1.0.1
Published
Helpers for handling files with Node.js, without dependencies (requireAll, requireToObj, RequireFiles, ...).
Downloads
3
Maintainers
Readme
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 Talle | | |