Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

ral

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ral

Path aliasing for require.

latest
Source
npmnpm
Version
1.1.1
Version published
Maintainers
1
Created
Source

Require ALias Build Status

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 ral.

For example if require-paths.json is:

{
   "constants" : "lib/constants"
}

Then the base path can be set in the index.js at the root of the project using:

require('ral').basePath = __dirname;

Then the module at lib/constants can be retrieved with:

require('ral')('constants')

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 constants above:

require('ral')('constants/something')

will give you lib/constants/something.

Source (~20 lines)

TODO: test on windows

Release Notes:

  • 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 ral.pathsConfig =
  • 2014-10-10 1.1.1 helpful errors if key is not found on require-paths

Keywords

paths

FAQs

Package last updated on 10 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts