mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-19 08:28:06 +02:00
Initial open-source release
This commit is contained in:
commit
1a42152e6f
1199 changed files with 257054 additions and 0 deletions
29
packages/context/src/core/git-env.ts
Normal file
29
packages/context/src/core/git-env.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import { simpleGit, type SimpleGit } from 'simple-git';
|
||||
|
||||
const GIT_HOOK_ENV_KEYS = [
|
||||
'GIT_ALTERNATE_OBJECT_DIRECTORIES',
|
||||
'GIT_DIR',
|
||||
'GIT_INDEX_FILE',
|
||||
'GIT_OBJECT_DIRECTORY',
|
||||
'GIT_PREFIX',
|
||||
'GIT_QUARANTINE_PATH',
|
||||
'GIT_WORK_TREE',
|
||||
'GIT_EDITOR',
|
||||
'GIT_EXEC_PATH',
|
||||
'GIT_PAGER',
|
||||
'PAGER',
|
||||
'VISUAL',
|
||||
'EDITOR',
|
||||
] as const;
|
||||
|
||||
function sanitizedGitEnv(env: NodeJS.ProcessEnv = process.env): NodeJS.ProcessEnv {
|
||||
const sanitized = { ...env };
|
||||
for (const key of GIT_HOOK_ENV_KEYS) {
|
||||
delete sanitized[key];
|
||||
}
|
||||
return sanitized;
|
||||
}
|
||||
|
||||
export function createSimpleGit(baseDir: string): SimpleGit {
|
||||
return simpleGit({ baseDir }).env(sanitizedGitEnv());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue