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
95 lines (71 loc) • 2.45 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.loadConsumer = loadConsumer;
exports.loadConsumerIfExist = loadConsumerIfExist;
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 _consumer() {
const data = _interopRequireDefault(require("./consumer"));
_consumer = function () {
return data;
};
return data;
}
function _exceptions() {
const data = require("./exceptions");
_exceptions = function () {
return data;
};
return data;
}
function loadConsumer() {
return _loadConsumer.apply(this, arguments);
}
function _loadConsumer() {
_loadConsumer = (0, _bluebird().coroutine)(function* ( // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
currentPath = process.cwd(), newInstance = false) {
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
if (newInstance || !loadConsumer.cache || !loadConsumer.cache[currentPath]) {
const consumer = yield _consumer().default.load(path().resolve(currentPath)); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
if (!loadConsumer.cache) loadConsumer.cache = {}; // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
loadConsumer.cache[currentPath] = consumer;
} // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
return loadConsumer.cache[currentPath];
});
return _loadConsumer.apply(this, arguments);
}
function loadConsumerIfExist() {
return _loadConsumerIfExist.apply(this, arguments);
}
function _loadConsumerIfExist() {
_loadConsumerIfExist = (0, _bluebird().coroutine)(function* ( // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
currentPath = process.cwd(), newInstance = false) {
try {
return yield loadConsumer(currentPath, newInstance);
} catch (err) {
if (err instanceof _exceptions().ConsumerNotFound) {
return undefined;
}
throw err;
}
});
return _loadConsumerIfExist.apply(this, arguments);
}
;