fix(hook): install from subdirectory

fix #199
This commit is contained in:
Hiroki Osame
2023-05-03 23:24:34 +09:00
parent dda7f8d424
commit 7631c2fc0b
4 changed files with 36 additions and 14 deletions

View File

@@ -2,11 +2,13 @@ import { execa } from 'execa';
import { KnownError } from './error.js';
export const assertGitRepo = async () => {
const { stdout } = await execa('git', ['rev-parse', '--is-inside-work-tree'], { reject: false });
const { stdout, failed } = await execa('git', ['rev-parse', '--show-toplevel'], { reject: false });
if (stdout !== 'true') {
if (failed) {
throw new KnownError('The current directory must be a Git repository!');
}
return stdout;
};
const excludeFromDiff = (path: string) => `:(exclude)${path}`;