Skip to content

Commit

Permalink
Use proper record type for env
Browse files Browse the repository at this point in the history
  • Loading branch information
niik committed May 21, 2024
1 parent a9e841c commit 5fb0659
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/git-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface IGitSpawnExecutionOptions {
* set as environment variables before executing the git
* process.
*/
readonly env?: object
readonly env?: Record<string, string | undefined>
}

/**
Expand All @@ -47,7 +47,7 @@ export interface IGitExecutionOptions {
* set as environment variables before executing the git
* process.
*/
readonly env?: object
readonly env?: Record<string, string | undefined>

/**
* An optional string or buffer which will be written to
Expand Down
2 changes: 1 addition & 1 deletion test/fast/errors-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
})

Expand Down
13 changes: 8 additions & 5 deletions test/slow/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function getAskPassTrampolinePath(): string {
return Path.join(projectRoot, 'test', 'auth', `ask-pass.${extension}`)
}

const defaultEnv = {
const defaultEnv: Record<string, string | undefined> = {
// supported since Git 2.3, this is used to ensure we never interactively prompt
// for credentials - even as a fallback
GIT_TERMINAL_PROMPT: '0',
Expand All @@ -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<string, string | undefined> {
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
}

0 comments on commit 5fb0659

Please sign in to comment.