@lerna/publish
Version:
Publish packages in the current project
72 lines (71 loc) • 3.18 kB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var symlink_binary_exports = {};
__export(symlink_binary_exports, {
symlinkBinary: () => symlinkBinary
});
module.exports = __toCommonJS(symlink_binary_exports);
var import_fs_extra = __toESM(require("fs-extra"));
var import_p_map = __toESM(require("p-map"));
var import_path = __toESM(require("path"));
var import_create_symlink = require("../create-symlink");
var import_package = require("../package");
function symlinkBinary(srcPackageRef, destPackageRef) {
return Promise.all([import_package.Package.lazy(srcPackageRef), import_package.Package.lazy(destPackageRef)]).then(
// TODO: refactor based on TS feedback
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
([srcPackage, destPackage]) => {
const actions = Object.keys(srcPackage.bin).map((name) => {
const srcLocation = srcPackage.contents ? import_path.default.resolve(srcPackage.location, srcPackage.contents) : srcPackage.location;
const src = import_path.default.join(srcLocation, srcPackage.bin[name]);
const dst = import_path.default.join(destPackage.binLocation, name);
return { src, dst };
});
if (actions.length === 0) {
return Promise.resolve();
}
return import_fs_extra.default.mkdirp(destPackage.binLocation).then(
() => (
// TODO: refactor based on TS feedback
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
(0, import_p_map.default)(actions, (meta) => {
if (meta) {
return (0, import_create_symlink.createSymlink)(meta.src, meta.dst, "exec");
}
})
)
);
}
);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
symlinkBinary
});