git-tweezers
Version:
Advanced git staging tool with hunk and line-level control
38 lines (37 loc) • 919 B
JavaScript
import { promises as fs } from 'node:fs';
import { homedir } from 'node:os';
import path from 'node:path';
import { execa } from 'execa';
export async function ensureDir(dir) {
await fs.mkdir(dir, { recursive: true });
}
export async function fileExists(p) {
try {
await fs.access(p);
return true;
}
catch {
return false;
}
}
export async function copyFile(src, dest) {
await fs.copyFile(src, dest);
}
export async function isGitRepository(dir = process.cwd()) {
try {
await execa('git', ['rev-parse', '--git-dir'], { cwd: dir });
return true;
}
catch {
return false;
}
}
export function getHomeDir() {
return homedir();
}
export function getClaudeCommandsDir(global = false) {
if (global) {
return path.join(getHomeDir(), '.claude', 'commands');
}
return path.join(process.cwd(), '.claude', 'commands');
}