From 5fb0659e9e69e5f4a3af52e2efeaaac13f6047d3 Mon Sep 17 00:00:00 2001 From: Markus Olsson Date: Tue, 21 May 2024 12:13:48 +0200 Subject: [PATCH] Use proper record type for env --- lib/git-process.ts | 4 ++-- test/fast/errors-test.ts | 2 +- test/slow/auth.ts | 13 ++++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/git-process.ts b/lib/git-process.ts index 8789fe50..c7ba0fb3 100644 --- a/lib/git-process.ts +++ b/lib/git-process.ts @@ -34,7 +34,7 @@ export interface IGitSpawnExecutionOptions { * set as environment variables before executing the git * process. */ - readonly env?: object + readonly env?: Record } /** @@ -47,7 +47,7 @@ export interface IGitExecutionOptions { * set as environment variables before executing the git * process. */ - readonly env?: object + readonly env?: Record /** * An optional string or buffer which will be written to diff --git a/test/fast/errors-test.ts b/test/fast/errors-test.ts index eeca6120..f3e88933 100644 --- a/test/fast/errors-test.ts +++ b/test/fast/errors-test.ts @@ -49,7 +49,7 @@ describe('detects errors', () => { const result = await GitProcess.exec(['status'], path, { env: { - GIT_TEST_ASSUME_DIFFERENT_OWNER: 1, + GIT_TEST_ASSUME_DIFFERENT_OWNER: '1', }, }) diff --git a/test/slow/auth.ts b/test/slow/auth.ts index 3a58edaf..dcd088bb 100644 --- a/test/slow/auth.ts +++ b/test/slow/auth.ts @@ -14,7 +14,7 @@ function getAskPassTrampolinePath(): string { return Path.join(projectRoot, 'test', 'auth', `ask-pass.${extension}`) } -const defaultEnv = { +const defaultEnv: Record = { // supported since Git 2.3, this is used to ensure we never interactively prompt // for credentials - even as a fallback GIT_TERMINAL_PROMPT: '0', @@ -24,16 +24,19 @@ const defaultEnv = { HOME: '', } -export function setupAskPass(username?: string, password?: string): object { - const auth = { +export function setupAskPass( + username?: string, + password?: string +): Record { + return { TEST_USERNAME: username, TEST_PASSWORD: password, ASKPASS_MAIN: getAskPassScriptPath(), GIT_ASKPASS: getAskPassTrampolinePath(), + ...defaultEnv, } - return Object.assign(auth, defaultEnv) } -export function setupNoAuth(): object { +export function setupNoAuth() { return defaultEnv }