UNPKG

@lerna/publish

Version:

Publish packages in the current project

66 lines (65 loc) 2.66 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; 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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var check_working_tree_exports = {}; __export(check_working_tree_exports, { checkWorkingTree: () => checkWorkingTree, mkThrowIfUncommitted: () => mkThrowIfUncommitted, throwIfReleased: () => throwIfReleased, throwIfUncommitted: () => throwIfUncommitted }); module.exports = __toCommonJS(check_working_tree_exports); var import_collect_uncommitted = require("./collect-uncommitted"); var import_describe_ref = require("./describe-ref"); var import_validation_error = require("./validation-error"); function checkWorkingTree({ cwd } = {}) { let chain = Promise.resolve(); chain = chain.then(() => (0, import_describe_ref.describeRef)({ cwd })); const tests = [ // prevent duplicate versioning chain.then(throwIfReleased), // prevent publish of uncommitted changes chain.then(mkThrowIfUncommitted({ cwd })) ]; return chain.then((result) => Promise.all(tests).then(() => result)); } function throwIfReleased({ refCount }) { if (refCount === "0") { throw new import_validation_error.ValidationError( "ERELEASED", "The current commit has already been released. Please make new commits before continuing." ); } } const EUNCOMMIT_MSG = "Working tree has uncommitted changes, please commit or remove the following changes before continuing:\n"; function mkThrowIfUncommitted(options = {}) { return function throwIfUncommitted2({ isDirty }) { if (isDirty) { return (0, import_collect_uncommitted.collectUncommitted)(options).then((uncommitted) => { throw new import_validation_error.ValidationError("EUNCOMMIT", `${EUNCOMMIT_MSG}${uncommitted.join("\n")}`); }); } }; } const throwIfUncommitted = mkThrowIfUncommitted(); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { checkWorkingTree, mkThrowIfUncommitted, throwIfReleased, throwIfUncommitted });