
Refractory
Synopsis
Refactory is a thin require wrapper that will allow you to search files in
conventional paths.
Description
When implementing CLI apps it's often a requirement to support "formatters",
"reporters" and various ".rc" files. In my case I needed to add support for formatters
to both curiosity and
hell. However, allowing users to implement
custom formatters is a nifty feature. This is how refractory was born.
Usage
var load = require('refractory')('../curiosity/formatters', '.curiosity/formatters');
var Formatter = load('my-awesome-formatter');
Refractory will try to load 'my-awesome-formatter' from the following paths:
- lib/curiosity/formatters/
- ~/.curiosity/formatters/
- node_modules/my-awesome-formatter
Errors
In case the requested file can't be found refractory will throw an error.
The error has the following extra properties:
- code - Always equals to "MODULE_NOT_FOUND"
- paths - An array of all of the variations that refractory try to load. Useful
for debugging issues
Installation
$ npm install refractory
Tests
Running the tests
$ npm test
Test coverage
$ npm run-script coverage
Support the author
Do you like this project? Star the repository, spread the word - it really helps. You may want to follow
me on Twitter and
GitHub. Thanks!
License
MIT License
Copyright (C) 2013 Veselin Todorov (hi@vesln.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.