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
148 lines (117 loc) • 4.19 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.addOne = addOne;
exports.addMany = addMany;
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 _addComponents() {
const data = _interopRequireDefault(require("../../../consumer/component-ops/add-components"));
_addComponents = function () {
return data;
};
return data;
}
function _consumer() {
const data = require("../../../consumer");
_consumer = function () {
return data;
};
return data;
}
function _constants() {
const data = require("../../../constants");
_constants = function () {
return data;
};
return data;
}
function _hooks() {
const data = _interopRequireDefault(require("../../../hooks"));
_hooks = function () {
return data;
};
return data;
}
const HooksManagerInstance = _hooks().default.getInstance();
function addOne(_x) {
return _addOne.apply(this, arguments);
}
function _addOne() {
_addOne = (0, _bluebird().coroutine)(function* (addProps) {
const consumer = yield (0, _consumer().loadConsumer)();
const addContext = {
consumer
};
const addComponents = new (_addComponents().default)(addContext, addProps);
const addResults = yield addComponents.add();
yield consumer.onDestroy();
const hookContext = {
workspacePath: consumer.getPath(),
bitmapFileName: _constants().BIT_MAP
}; // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
yield HooksManagerInstance.triggerHook(_constants().POST_ADD_HOOK, addResults, null, hookContext);
return addResults;
});
return _addOne.apply(this, arguments);
}
function addMany(_x2, _x3) {
return _addMany.apply(this, arguments);
}
function _addMany() {
_addMany = (0, _bluebird().coroutine)(function* (components, alternateCwd) {
// we are checking whether the consumer is the default consumer which is process.cwd() or it is overriden , and we are working on another directory which is not the process.cwd()
const consumerPath = alternateCwd || process.cwd();
const consumer = yield (0, _consumer().loadConsumer)(consumerPath);
const addContext = {
consumer,
alternateCwd: consumerPath
};
const addComponentsArr = [];
components.forEach(component => {
const normalizedPaths = component.componentPaths.map(p => {
return path().normalize(p);
});
component.componentPaths = normalizedPaths;
const normalizedTests = component.tests ? component.tests.map(testFile => path().normalize(testFile.trim())) : [];
component.tests = normalizedTests;
component.exclude = component.exclude ? component.exclude.map(excludeFile => path().normalize(excludeFile.trim())) : [];
const addComponents = new (_addComponents().default)(addContext, component); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
addComponentsArr.push(addComponents);
});
const addResults = [];
yield Promise.all(addComponentsArr.map( /*#__PURE__*/function () {
var _ref = (0, _bluebird().coroutine)(function* (addComponents) {
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
const addResultsSingle = yield addComponents.add(); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
addResults.push(addResultsSingle);
});
return function (_x4) {
return _ref.apply(this, arguments);
};
}()));
yield consumer.onDestroy();
const hookContext = {
workspacePath: consumer.getPath(),
bitmapFileName: _constants().BIT_MAP
}; // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
yield HooksManagerInstance.triggerHook(_constants().POST_ADD_HOOK, addResults, null, hookContext);
return addResults;
});
return _addMany.apply(this, arguments);
}
;