unbag
Version:
一个专门用来开发npm工具的包
40 lines (39 loc) • 932 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useGit = void 0;
var _execa = require("execa");
const useGit = () => {
const currentBranchGet = async () => {
const {
stdout
} = await (0, _execa.$)`git rev-parse --abbrev-ref HEAD`;
return stdout;
};
const currentBranchStatusGet = async () => {
const {
stdout
} = await (0, _execa.$)`git status -s`;
return stdout;
};
const gitRootPathGet = async () => {
const {
stdout
} = await (0, _execa.$)`git rev-parse --show-toplevel`;
return stdout.trim();
};
const stageFilesGet = async () => {
const {
stdout
} = await (0, _execa.$)`git diff --cached --no-ext-diff --name-only`;
return stdout.trim().split("\n").filter(e => e);
};
return {
currentBranchGet,
currentBranchStatusGet,
gitRootPathGet,
stageFilesGet
};
};
exports.useGit = useGit;