UNPKG

@lerna/publish

Version:

Publish packages in the current project

60 lines (59 loc) 3.06 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 collect_uncommitted_exports = {}; __export(collect_uncommitted_exports, { collectUncommitted: () => collectUncommitted, collectUncommittedSync: () => collectUncommittedSync }); module.exports = __toCommonJS(collect_uncommitted_exports); var import_chalk = __toESM(require("chalk")); var import_npmlog = __toESM(require("npmlog")); const childProcess = require("@lerna/child-process"); const maybeColorize = (colorize) => (s) => s !== " " ? colorize(s) : s; const cRed = maybeColorize(import_chalk.default.red); const cGreen = maybeColorize(import_chalk.default.green); const replaceStatus = (_, maybeGreen, maybeRed) => `${cGreen(maybeGreen)}${cRed(maybeRed)}`; const colorizeStats = (stats) => stats.replace(/^([^U]| )([A-Z]| )/gm, replaceStatus).replace(/^\?{2}|U{2}/gm, cRed("$&")); const splitOnNewLine = (str) => str.split("\n"); const filterEmpty = (lines) => lines.filter((line) => line.length); const o = (l, r) => (x) => l(r(x)); const transformOutput = o(filterEmpty, o(splitOnNewLine, colorizeStats)); function collectUncommitted({ cwd, log = import_npmlog.default }) { log.silly("collect-uncommitted", "git status --porcelain (async)"); return childProcess.exec("git", ["status", "--porcelain"], { cwd }).then(({ stdout }) => transformOutput(stdout)); } function collectUncommittedSync({ cwd, log = import_npmlog.default }) { log.silly("collect-uncommitted", "git status --porcelain (sync)"); const stdout = childProcess.execSync("git", ["status", "--porcelain"], { cwd }); return transformOutput(stdout); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { collectUncommitted, collectUncommittedSync });