module-alias
Advanced tools
Comparing version 2.0.0 to 2.0.1
11
index.js
@@ -8,2 +8,3 @@ 'use strict' | ||
var moduleAliases = {} | ||
var moduleAliasNames = []; | ||
@@ -25,3 +26,4 @@ var oldNodeModulePaths = Module._nodeModulePaths | ||
Module._resolveFilename = function (request, parent, isMain) { | ||
for (var alias in moduleAliases) { | ||
for (var i = moduleAliasNames.length; i-- > 0;) { | ||
var alias = moduleAliasNames[i] | ||
if (isPathMatchesAlias(request, alias)) { | ||
@@ -32,2 +34,4 @@ request = nodePath.join( | ||
) | ||
// Only use the first match | ||
break | ||
} | ||
@@ -92,2 +96,5 @@ } | ||
moduleAliases[alias] = target | ||
// Cost of sorting is lower here than during resolution | ||
moduleAliasNames = Object.keys(moduleAliases) | ||
moduleAliasNames.sort() | ||
} | ||
@@ -139,3 +146,3 @@ | ||
if (typeof npmPackage !== 'object') { | ||
throw Error('Unable to read ' + base + '/package.json') | ||
throw new Error('Unable to read ' + base + '/package.json') | ||
} | ||
@@ -142,0 +149,0 @@ |
{ | ||
"name": "module-alias", | ||
"description": "Create aliases of directories and register custom module paths in NodeJS like a boss!", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Nick Gavrilov", |
@@ -30,3 +30,3 @@ # module-alias | ||
**WARNING:** This module should not be used in other npm modules since it modifies the default `require` behavior! It is designed to be used for developing of projects such as web-sites, applications etc. | ||
**WARNING:** This module should not be used in other npm modules since it modifies the default `require` behavior! It is designed to be used for development of final projects i.e. web-sites, applications etc. | ||
@@ -33,0 +33,0 @@ ## Install |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9790
148