@pnpm/plugin-commands-publishing
Version:
The pack and publish commands of pnpm
49 lines • 1.47 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isRemoteHistoryClean = exports.isWorkingTreeClean = exports.getCurrentBranch = exports.isGitRepo = void 0;
const execa = require("execa");
// git checks logic is from https://github.com/sindresorhus/np/blob/master/source/git-tasks.js
async function isGitRepo() {
try {
await execa('git', ['rev-parse', '--git-dir']);
}
catch (_) {
return false;
}
return true;
}
exports.isGitRepo = isGitRepo;
async function getCurrentBranch() {
const { stdout } = await execa('git', ['symbolic-ref', '--short', 'HEAD']);
return stdout;
}
exports.getCurrentBranch = getCurrentBranch;
async function isWorkingTreeClean() {
try {
const { stdout: status } = await execa('git', ['status', '--porcelain']);
if (status !== '') {
return false;
}
return true;
}
catch (_) {
return false;
}
}
exports.isWorkingTreeClean = isWorkingTreeClean;
async function isRemoteHistoryClean() {
let history;
try { // Gracefully handle no remote set up.
const { stdout } = await execa('git', ['rev-list', '--count', '--left-only', '@{u}...HEAD']);
history = stdout;
}
catch (_) {
history = null;
}
if (history && history !== '0') {
return false;
}
return true;
}
exports.isRemoteHistoryClean = isRemoteHistoryClean;
//# sourceMappingURL=gitChecks.js.map