bit-bin
Version:
<a href="https://opensource.org/licenses/Apache-2.0"><img alt="apache" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> <a href="https://github.com/teambit/bit/blob/master/CONTRIBUTING.md"><img alt="prs" src="https://img.shields.io/b
91 lines (68 loc) • 1.81 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = loadScope;
exports.loadScopeIfExist = loadScopeIfExist;
function _bluebird() {
const data = require("bluebird");
_bluebird = function () {
return data;
};
return data;
}
function path() {
const data = _interopRequireWildcard(require("path"));
path = function () {
return data;
};
return data;
}
function _scope() {
const data = _interopRequireDefault(require("./scope"));
_scope = function () {
return data;
};
return data;
}
function _utils() {
const data = require("../utils");
_utils = function () {
return data;
};
return data;
}
function _exceptions() {
const data = require("./exceptions");
_exceptions = function () {
return data;
};
return data;
}
function loadScope(currentPath, useCache = true) {
if (!currentPath) currentPath = process.cwd();
try {
return _scope().default.load(path().resolve((0, _utils().resolveHomePath)(currentPath)), useCache);
} catch (err) {
return Promise.reject(err);
}
}
function loadScopeIfExist() {
return _loadScopeIfExist.apply(this, arguments);
}
function _loadScopeIfExist() {
_loadScopeIfExist = (0, _bluebird().coroutine)(function* ( // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
currentPath = process.cwd(), useCache = true) {
try {
return yield loadScope(currentPath, useCache);
} catch (err) {
if (err instanceof _exceptions().ScopeNotFound) {
return undefined;
}
throw err;
}
});
return _loadScopeIfExist.apply(this, arguments);
}
;