lerna
Version:
Lerna is a fast, modern build system for managing and publishing multiple JavaScript/TypeScript packages from the same repository
33 lines (30 loc) • 887 B
JavaScript
import {
execSync,
npmlog_default
} from "./chunk-WC2B4V4E.js";
// libs/commands/version/src/lib/is-behind-upstream.ts
function isBehindUpstream(gitRemote, branch, opts) {
npmlog_default.silly("isBehindUpstream", "");
updateRemote(opts);
const remoteBranch = `${gitRemote}/${branch}`;
const [behind, ahead] = countLeftRight(`${remoteBranch}...${branch}`, opts);
npmlog_default.silly(
"isBehindUpstream",
`${branch} is behind ${remoteBranch} by ${behind} commit(s) and ahead by ${ahead}`
);
return Boolean(behind);
}
function updateRemote(opts) {
execSync("git", ["remote", "update"], opts);
}
function countLeftRight(symmetricDifference, opts) {
const stdout = execSync(
"git",
["rev-list", "--left-right", "--count", symmetricDifference],
opts
);
return stdout.split(" ").map((val) => parseInt(val, 10));
}
export {
isBehindUpstream
};