@synstack/git
Version:
Git utilities for AI prompting and automation
45 lines (44 loc) • 1.07 kB
JavaScript
var __defProp = Object.defineProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
// src/git.lib.ts
var git_lib_exports = {};
__export(git_lib_exports, {
ls: () => ls,
show: () => show
});
import { execa } from "execa";
import { execPipe, filter, flatMap } from "iter-tools-es";
async function ls(cwd = ".") {
const [trackedFiles, modifiedFiles, untrackedFiles] = await Promise.all([
execa({
cwd
})`git ls-files`,
execa({
cwd
})`git ls-files -m`,
execa({
cwd
})`git ls-files --others --exclude-standard`
]);
const files = execPipe(
[trackedFiles, modifiedFiles, untrackedFiles],
flatMap((r) => r.stdout.split("\n")),
filter((l) => l.trim().length > 0)
);
return [...new Set(files)].sort();
}
async function show(commitId, cwd = ".") {
const res = await execa({
cwd
})`git show ${commitId}`;
return res.stdout.trim();
}
export {
git_lib_exports as git,
ls,
show
};
//# sourceMappingURL=git.index.js.map