mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-27 02:45:14 +00:00
32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
|
"use strict";
|
||
|
|
||
|
Object.defineProperty(exports, "__esModule", {
|
||
|
value: true
|
||
|
});
|
||
|
exports.default = _default;
|
||
|
|
||
|
var _path = _interopRequireDefault(require("path"));
|
||
|
|
||
|
var _resolve = _interopRequireDefault(require("resolve"));
|
||
|
|
||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
|
||
|
function _default(moduleName, dirname, absoluteRuntime) {
|
||
|
if (absoluteRuntime === false) return moduleName;
|
||
|
return resolveAbsoluteRuntime(moduleName, _path.default.resolve(dirname, absoluteRuntime === true ? "." : absoluteRuntime));
|
||
|
}
|
||
|
|
||
|
function resolveAbsoluteRuntime(moduleName, dirname) {
|
||
|
try {
|
||
|
return _path.default.dirname(_resolve.default.sync(`${moduleName}/package.json`, {
|
||
|
basedir: dirname
|
||
|
})).replace(/\\/g, "/");
|
||
|
} catch (err) {
|
||
|
if (err.code !== "MODULE_NOT_FOUND") throw err;
|
||
|
throw Object.assign(new Error(`Failed to resolve "${moduleName}" relative to "${dirname}"`), {
|
||
|
code: "BABEL_RUNTIME_NOT_FOUND",
|
||
|
runtime: moduleName,
|
||
|
dirname
|
||
|
});
|
||
|
}
|
||
|
}
|