Comparing version 0.0.1 to 0.0.2
@@ -36,30 +36,39 @@ /*! | ||
const paths = [ | ||
// node-gyp's linked version in the "build" dir | ||
['root', 'build', 'name'], | ||
// node-waf and gyp_addon (a.k.a node-gyp) | ||
['root', 'build', 'Debug', 'name'], | ||
['root', 'build', 'Release', 'name'], | ||
// Debug files, for development (legacy behavior) | ||
['root', 'out', 'Debug', 'name'], | ||
['root', 'Debug', 'name'], | ||
// Release files, but manually compiled (legacy behavior) | ||
['root', 'out', 'Release', 'name'], | ||
['root', 'Release', 'name'], | ||
// Legacy from node-waf, node <= 0.4.x | ||
['root', 'build', 'default', 'name'], | ||
// Production "Release" buildtype binary (meh...) | ||
['root', 'compiled', 'version', 'platform', 'arch', 'name'], | ||
// node-gyp's linked version in the "build" dir. | ||
['$root', 'build', '$name'], | ||
// node-waf and gyp_addon (a.k.a node-gyp). | ||
['$root', 'build', 'Debug', '$name'], | ||
['$root', 'build', 'Release', '$name'], | ||
// Raw CMake (single-configuration, e.g. make). | ||
['$root', '$name'], | ||
// Raw CMake (multi-configuration, e.g. msvs, xcode). | ||
['$root', 'Debug', '$name'], | ||
['$root', 'Release', '$name'], | ||
['$root', 'MinSizeRel', '$name'], | ||
['$root', 'RelWithDebInfo', '$name'], | ||
// Debug files, for development (legacy behavior). | ||
['$root', 'out', 'Debug', '$name'], | ||
['$root', 'Debug', '$name'], | ||
// Release files, but manually compiled (legacy behavior). | ||
['$root', 'out', 'Release', '$name'], | ||
['$root', 'Release', '$name'], | ||
// Legacy from node-waf, node <= 0.4.x. | ||
['$root', 'build', 'default', '$name'], | ||
// Production "Release" buildtype binary (meh...). | ||
['$root', '$compiled', '$version', '$platform', '$arch', '$name'], | ||
// node-qbs builds | ||
['root', 'addon-build', 'release', 'install-root', 'name'], | ||
['root', 'addon-build', 'debug', 'install-root', 'name'], | ||
['root', 'addon-build', 'default', 'install-root', 'name'], | ||
// node-pre-gyp path ./lib/binding/{node_abi}-{platform}-{arch} | ||
['root', 'lib', 'binding', 'pregyp', 'name'] | ||
['$root', 'addon-build', 'release', 'install-root', '$name'], | ||
['$root', 'addon-build', 'debug', 'install-root', '$name'], | ||
['$root', 'addon-build', 'default', 'install-root', '$name'], | ||
// node-pre-gyp path ./lib/binding/{node_abi}-{platform}-{arch}. | ||
['$root', 'lib', 'binding', '$pregyp', '$name'] | ||
]; | ||
const cache = Object.create(null); | ||
/** | ||
* Bindings | ||
* Loady | ||
*/ | ||
function bindings(name, path) { | ||
function loady(name, path) { | ||
if (typeof name !== 'string') | ||
@@ -71,7 +80,12 @@ throw new TypeError('"name" must be a string.'); | ||
const root = getRoot(ensurePath(path)); | ||
if (extname(name) !== '.node') | ||
name += '.node'; | ||
path = ensurePath(path); | ||
const key = `${name}\0${path}`; | ||
if (cache[key]) | ||
return cache[key]; | ||
const loader = typeof __webpack_require__ === 'function' | ||
@@ -84,3 +98,3 @@ ? __non_webpack_require__ | ||
options.root = root; | ||
options.root = getRoot(path); | ||
options.name = name; | ||
@@ -91,4 +105,8 @@ | ||
for (const part of parts) | ||
names.push(options[part] || part); | ||
for (const part of parts) { | ||
if (part[0] === '$') | ||
names.push(options[part.substring(1)]); | ||
else | ||
names.push(part); | ||
} | ||
@@ -116,2 +134,4 @@ const file = join(...names); | ||
cache[key] = binding; | ||
return binding; | ||
@@ -176,2 +196,2 @@ } | ||
module.exports = bindings; | ||
module.exports = loady; |
{ | ||
"name": "loady", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "dynamic loader for node.js", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
6955
148