UNPKG

@lerna/publish

Version:

Publish packages in the current project

90 lines (89 loc) 3.47 kB
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 cli_exports = {}; __export(cli_exports, { cliRunner: () => cliRunner, commandRunner: () => commandRunner }); module.exports = __toCommonJS(cli_exports); var import_execa = __toESM(require("execa")); var import_path = __toESM(require("path")); function commandRunner(commandModule) { const cmd = commandModule.command.split(" ")[0]; const { lernaCLI } = require("@lerna/core"); require(import_path.default.resolve(require.main.filename, "../../")); return (cwd) => { const cli = lernaCLI([], cwd).exitProcess(false).detectLocale(false).showHelpOnFail(false).wrap(null).command(commandModule); return (...args) => new Promise((resolve, reject) => { const yargsMeta = {}; const context = { cwd, lernaVersion: "__TEST_VERSION__", loglevel: "silent", progress: false, onResolved: (result) => { resolve(Object.assign({}, result, yargsMeta)); }, onRejected: (result) => { Object.assign(result, yargsMeta); reject(result); } }; const parseFn = (yargsError, parsedArgv, yargsOutput) => { Object.assign(yargsMeta, { parsedArgv, yargsOutput }); }; cli.fail((msg, err) => { const actual = err || new Error(msg); yargsMeta.exitCode = "exitCode" in actual ? actual.exitCode : 1; context.onRejected(actual); }).parse([cmd, ...args], context, parseFn); }); }; } function cliRunner(cwd, env) { const opts = { cwd, env: Object.assign( { CI: "true", // always turn off chalk FORCE_COLOR: "0" }, env ) // when debugging integration test snapshots, uncomment next line // stdio: ["ignore", "inherit", "inherit"], }; const LERNA_BIN = require.resolve((0, import_path.join)(__dirname, "../../../../", "packages/lerna/dist/cli")); return (...args) => (0, import_execa.default)("node", [LERNA_BIN].concat(args), opts); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { cliRunner, commandRunner });