Require path aliasing.
This module allows you to easily move files and directories in your app without having to update many require calls. Instead you update the relevant alias definition.
The paths aliases to be used are defined in
require-paths.json. All the paths are relative to
the directory this file is in. To configure this directory you must set
ral.basePath before your first usage of
For example if
Then the base path can be set in the
index.js at the root of the project using:
basePath = __dirname;
Then the module at
lib/constants can be retrieved with:
If the location of constants changes, only
require-paths.json needs to be updated.
A path can be added after the key. For example given
will give you
TODO: test on windows
- 2014-06-02 0.0.1 Initial Release
- 2014-06-03 0.1.0 Added tests & process.env.REQUIRE_PATHS
- 2014-06-03 0.1.1 Locking down node version to >=0.8
- 2014-06-04 0.1.2 Removing hard coded path separator
- 2014-07-10 1.0.0 ral is dynamically configurable
- 2014-10-01 1.1.0 the json object ral uses as its configuration can now be directly modified w
- 2014-10-10 1.1.1 helpful errors if key is not found on require-paths