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
111 lines (85 loc) • 3.07 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.symlinkCapsulesInNodeModules = symlinkCapsulesInNodeModules;
exports.removeExistingLinksInNodeModules = removeExistingLinksInNodeModules;
function _bluebird() {
const data = require("bluebird");
_bluebird = function () {
return data;
};
return data;
}
function _fsExtra() {
const data = _interopRequireDefault(require("fs-extra"));
_fsExtra = function () {
return data;
};
return data;
}
function _path() {
const data = _interopRequireDefault(require("path"));
_path = function () {
return data;
};
return data;
}
function _componentIdToPackageName() {
const data = _interopRequireDefault(require("../../utils/bit/component-id-to-package-name"));
_componentIdToPackageName = function () {
return data;
};
return data;
}
function _constants() {
const data = require("../../constants");
_constants = function () {
return data;
};
return data;
}
function symlinkCapsulesInNodeModules(_x) {
return _symlinkCapsulesInNodeModules.apply(this, arguments);
}
function _symlinkCapsulesInNodeModules() {
_symlinkCapsulesInNodeModules = (0, _bluebird().coroutine)(function* (isolatedEnvs) {
yield Promise.all(isolatedEnvs.map( /*#__PURE__*/function () {
var _ref = (0, _bluebird().coroutine)(function* (e) {
const componentPackageName = (0, _componentIdToPackageName().default)(e.component.id.legacyComponentId, _constants().DEFAULT_REGISTRY_DOMAIN_PREFIX);
const linkPath = _path().default.join(process.cwd(), 'node_modules', componentPackageName);
yield _fsExtra().default.mkdirp(_path().default.dirname(linkPath));
yield _fsExtra().default.symlink(e.capsule.wrkDir, linkPath);
});
return function (_x3) {
return _ref.apply(this, arguments);
};
}()));
});
return _symlinkCapsulesInNodeModules.apply(this, arguments);
}
function removeExistingLinksInNodeModules(_x2) {
return _removeExistingLinksInNodeModules.apply(this, arguments);
}
function _removeExistingLinksInNodeModules() {
_removeExistingLinksInNodeModules = (0, _bluebird().coroutine)(function* (isolatedEnvs) {
yield Promise.all(isolatedEnvs.map( /*#__PURE__*/function () {
var _ref2 = (0, _bluebird().coroutine)(function* (e) {
const componentPackageName = (0, _componentIdToPackageName().default)(e.component.id.legacyComponentId, _constants().DEFAULT_REGISTRY_DOMAIN_PREFIX);
try {
yield _fsExtra().default.unlink(_path().default.join(process.cwd(), 'node_modules', componentPackageName));
} catch (err) {
// if the symlink does not exist - no problem
if (err.code !== 'ENOENT') {
throw err;
}
}
});
return function (_x4) {
return _ref2.apply(this, arguments);
};
}()));
});
return _removeExistingLinksInNodeModules.apply(this, arguments);
}
;