@coveo/semantic-monorepo-tools
Version:
A library of helper functions to do SemVer2 compliant releases from Conventional Commits in monorepos
24 lines (23 loc) • 831 B
JavaScript
import spawn from "../utils/spawn.js";
import appendCmdIfWindows from "./utils/appendCmdIfWindows.js";
import npmLogger from "./utils/npmLogger.js";
const DefaultOptions = {
workspaceUpdateStrategy: "NoUpdate",
};
export default async function (newVersion, PATH, options) {
const completeOptions = { ...DefaultOptions, ...options };
const npmArgs = ["version", newVersion, "--git-tag-version=false"].concat(computeFlagsFromOptions(completeOptions));
await spawn(appendCmdIfWindows `npm`, npmArgs, npmLogger, {
cwd: PATH,
});
}
function computeFlagsFromOptions(options) {
switch (options.workspaceUpdateStrategy) {
case "NoUpdate":
return [];
case "UpdateExact":
return ["--save", "-E"];
case "UpdateWithCarret":
return ["--save"];
}
}