magic-variables
Magic variables for Node.js
Installation
npm install --save magic-variables
Usage
Simply add this to your top-most file, something like bootloader. No need to assign it to a variable, it can be accessible globally.
Basic variables:
require('magic-variables');
console.log(__magic.package);
console.log(require(__magic.package).version);
console.log(__magic.base);
console.log(__magic.filename);
console.log(__magic.file);
console.log(__magic.extension);
console.log(__magic.line);
console.log(__magic.column);
console.log(__magic.info);
console.log(__magic.function);
Mapping:
Create .magicrc
file in your application root and put these lines in it:
{
"api" : "routes/api",
"config" : "config.js",
"lib" : "lib/"
}
Note: Do not use the reserved words: package, base, filename, file, extension, line, column, info and function. Also, not class or method too which are reserved for planned features.
console.log(__magic.api);
console.log(__magic.config);
console.log(__magic.lib);
TODO
Planned features:
__magic.class
__magic.method
Contribution
Any contributions are more than welcome!
License
MIT © Gökay Gürcan