Skip to content

Commit 5f296da

Browse files
committed
Fix Windows CI tests
1 parent 9fb3d20 commit 5f296da

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/commands/fix/cmd-fix.test.mts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ describe('socket fix', async () => {
6262
'should require args with just dry-run',
6363
async cmd => {
6464
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
65-
expect(stdout).toMatchInlineSnapshot(`
66-
"\\x1b[34mi\\x1b[39m Fixing packages for npm
67-
[DryRun]: Not saving"
68-
`)
6965
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
7066
"
7167
_____ _ _ /---------------
@@ -75,6 +71,10 @@ describe('socket fix', async () => {
7571
7672
\\x1b[33m\\u203c\\x1b[39m socket fix: Package package-lock.json found at <redacted>"
7773
`)
74+
expect(stdout).toMatchInlineSnapshot(`
75+
"\\x1b[34mi\\x1b[39m Fixing packages for npm
76+
[DryRun]: Not saving"
77+
`)
7878
expect(code, 'dry-run should exit with code 0 if input ok').toBe(0)
7979
}
8080
)

src/utils/package-environment.mts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import semver from 'semver'
66
import which from 'which'
77

88
import { parse as parseBunLockb } from '@socketregistry/hyrious__bun.lockb/index.cjs'
9+
import { debugLog } from '@socketsecurity/registry/lib/debug'
910
import { Logger } from '@socketsecurity/registry/lib/logger'
1011
import { readPackageJson } from '@socketsecurity/registry/lib/packages'
1112
import { naturalCompare } from '@socketsecurity/registry/lib/sorts'
@@ -50,6 +51,10 @@ const binByAgent = new Map<Agent, string>([
5051

5152
async function getAgentExecPath(agent: Agent): Promise<string> {
5253
const binName = binByAgent.get(agent)!
54+
if (binName === NPM) {
55+
// Lazily access constants.npmExecPath.
56+
return constants.npmExecPath
57+
}
5358
return (await which(binName, { nothrow: true })) ?? binName
5459
}
5560

@@ -67,8 +72,8 @@ async function getAgentVersion(
6772
// All package managers support the "--version" flag.
6873
(await spawn(agentExecPath, ['--version'], { cwd })).stdout
6974
) ?? undefined
70-
} catch (e){
71-
console.log(e)
75+
} catch (e) {
76+
debugLog('getAgentVersion error:\n', e)
7277
}
7378
return result
7479
}
@@ -399,7 +404,6 @@ export async function detectAndValidatePackageEnvironment(
399404
const agentVersion = details.agentVersion ?? 'unknown'
400405
if (!details.agentSupported) {
401406
const minVersion = constants.minimumVersionByAgent.get(agent)!
402-
console.dir({ details }, { depth: 999 })
403407
logger?.fail(
404408
cmdPrefixMessage(
405409
cmdName,

0 commit comments

Comments
 (0)