Skip to content

Commit dc5176c

Browse files
committed
Add debug logging to getFixEnv
1 parent 022258d commit dc5176c

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/commands/fix/fix-env-helpers.mts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { debugFn } from '@socketsecurity/registry/lib/debug'
1+
import { joinAnd } from '@socketsecurity/registry/lib/arrays'
2+
import { debugFn, isDebug } from '@socketsecurity/registry/lib/debug'
23

34
import { getSocketPrs } from './pull-request.mts'
45
import constants from '../../constants.mts'
@@ -40,6 +41,27 @@ export async function getFixEnv(): Promise<FixEnv> {
4041
const gitUser = constants.ENV.SOCKET_CLI_GIT_USER_NAME
4142
const githubToken = constants.ENV.SOCKET_CLI_GITHUB_TOKEN
4243
const isCi = !!(constants.ENV.CI && gitEmail && gitUser && githubToken)
44+
45+
if (
46+
// If isCi is false,
47+
!isCi &&
48+
// but some CI checks are passing,
49+
(constants.ENV.CI || gitEmail || gitUser || githubToken) &&
50+
// then log about it when in debug mode.
51+
isDebug('notice')
52+
) {
53+
const things = [
54+
...(constants.ENV.CI ? [] : ['process.env.CI']),
55+
...(gitEmail ? [] : ['process.env.SOCKET_CLI_GIT_USER_EMAIL']),
56+
...(gitUser ? [] : ['process.env.SOCKET_CLI_GIT_USER_NAME']),
57+
...(githubToken ? [] : ['process.env.GITHUB_TOKEN']),
58+
]
59+
debugFn(
60+
'notice',
61+
`miss: fixEnv.isCi is false, expected ${joinAnd(things)} to be set`,
62+
)
63+
}
64+
4365
let repoInfo: RepoInfo | null = null
4466
if (isCi) {
4567
repoInfo = ciRepoInfo()
@@ -50,13 +72,15 @@ export async function getFixEnv(): Promise<FixEnv> {
5072
}
5173
repoInfo = await getRepoInfo()
5274
}
75+
5376
const prs =
5477
isCi && repoInfo
5578
? await getSocketPrs(repoInfo.owner, repoInfo.repo, {
5679
author: gitUser,
5780
states: 'all',
5881
})
5982
: []
83+
6084
return {
6185
baseBranch,
6286
gitEmail,

0 commit comments

Comments
 (0)