bare-addon-resolve
Advanced tools
Comparing version 1.3.0 to 1.4.0
42
index.js
@@ -233,7 +233,49 @@ const resolve = require('bare-module-resolve') | ||
if (yield * exports.linked(name, version, opts)) { | ||
yielded = true | ||
} | ||
return yielded | ||
} | ||
exports.linked = function * (name, version = null, opts = {}) { | ||
const { linked = true, linkedProtocol = 'linked:', host = null } = opts | ||
if (linked === false || host === null) return false | ||
if (host.startsWith('darwin-') || host.startsWith('ios-')) { | ||
if (version !== null) { | ||
yield { resolution: new URL(linkedProtocol + 'lib' + name + '.' + version + '.dylib') } | ||
} | ||
yield { resolution: new URL(linkedProtocol + 'lib' + name + '.dylib') } | ||
return true | ||
} | ||
if (host.startsWith('linux-') || host.startsWith('android-')) { | ||
if (version !== null) { | ||
yield { resolution: new URL(linkedProtocol + 'lib' + name + '.so.' + version) } | ||
} | ||
yield { resolution: new URL(linkedProtocol + 'lib' + name + '.so') } | ||
return true | ||
} | ||
if (host.startsWith('win32-')) { | ||
if (version !== null) { | ||
yield { resolution: new URL(linkedProtocol + name + '-' + version + '.dll') } | ||
} | ||
yield { resolution: new URL(linkedProtocol + name + '.dll') } | ||
return true | ||
} | ||
return false | ||
} | ||
exports.isWindowsDriveLetter = resolve.isWindowsDriveLetter | ||
exports.startsWithWindowsDriveLetter = resolve.startsWithWindowsDriveLetter |
{ | ||
"name": "bare-addon-resolve", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Low-level addon resolution algorithm for Bare", | ||
"main": "index.js", | ||
"exports": { | ||
".": "./index.js", | ||
"./package": "./package.json", | ||
"./errors": "./lib/errors.js" | ||
}, | ||
"files": [ | ||
@@ -7,0 +11,0 @@ "index.js", |
@@ -60,2 +60,6 @@ # bare-addon-resolve | ||
builtinProtocol: 'builtin:', | ||
// Whether or not addons linked ahead-of-time should be resolved. | ||
linked: true, | ||
// The protocol to use for addons linked ahead-of-time. | ||
linkedProtocol: 'linked:', | ||
// The `<platform>-<arch>` combination to look for when resolving dynamic | ||
@@ -117,4 +121,6 @@ // addons. If `null`, only builtin specifiers can be resolved. In Bare, | ||
#### `const generator = resolve.linked(name, version[, options])` | ||
## License | ||
Apache-2.0 |
24266
219
125