UNPKG

unbag

Version:

一个专门用来开发npm工具的包

34 lines 769 B
import { $ } from "execa"; const useGit = () => { const currentBranchGet = async () => { const { stdout } = await $`git rev-parse --abbrev-ref HEAD`; return stdout; }; const currentBranchStatusGet = async () => { const { stdout } = await $`git status -s`; return stdout; }; const gitRootPathGet = async () => { const { stdout } = await $`git rev-parse --show-toplevel`; return stdout.trim(); }; const stageFilesGet = async () => { const { stdout } = await $`git diff --cached --no-ext-diff --name-only`; return stdout.trim().split("\n").filter(e => e); }; return { currentBranchGet, currentBranchStatusGet, gitRootPathGet, stageFilesGet }; }; export { useGit };