amd-name-resolver
Advanced tools
Comparing version 0.0.2 to 0.0.3
23
index.js
@@ -0,1 +1,16 @@ | ||
module.exports = moduleResolve; | ||
var throwOnRootAccess = true; | ||
exports.resolveModules = function resolveModules(options) { | ||
options = options || {}; | ||
if (options.throwOnRootAccess === false) { | ||
throwOnRootAccess = false; | ||
} | ||
return moduleResolve; | ||
} | ||
function moduleResolve(child, name) { | ||
@@ -13,3 +28,7 @@ if (child.charAt(0) !== '.') { return child; } | ||
if (parentBase.length === 0) { | ||
throw new Error('Cannot access parent module of root'); | ||
if (throwOnRootAccess) { | ||
throw new Error('Cannot access parent module of root'); | ||
} else { | ||
continue; | ||
} | ||
} | ||
@@ -25,3 +44,1 @@ parentBase.pop(); | ||
} | ||
module.exports = moduleResolve; |
{ | ||
"name": "amd-name-resolver", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "AMD module name resolver algorithm", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,2 +5,3 @@ 'use strict'; | ||
var moduleResolve = require('./index'); | ||
var resolveModules = moduleResolve.resolveModules; | ||
@@ -25,2 +26,9 @@ describe('module resolver', function () { | ||
}); | ||
it('should not throw if specified', function() { | ||
expect(function() { | ||
var r = resolveModules({ throwOnRootAccess: false }); | ||
return r('../../bizz', 'example') | ||
}).to.not.throw(/Cannot access parent module of root/); | ||
}); | ||
}); |
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
2312
56