Skip to content

Commit 16d98ce

Browse files
committed
Fix tests on Windows
1 parent 12352ae commit 16d98ce

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

.config/rollup.dist.config.mjs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
fetchPackageManifest,
2222
readPackageJson,
2323
} from '@socketsecurity/registry/lib/packages'
24+
import { normalizePath } from '@socketsecurity/registry/lib/path'
2425
import { escapeRegExp } from '@socketsecurity/registry/lib/regexps'
2526
import { naturalCompare } from '@socketsecurity/registry/lib/sorts'
2627

@@ -356,13 +357,19 @@ function resetDependencies(deps) {
356357
export default async () => {
357358
// Lazily access constants path properties.
358359
const { configPath, distPath, rootPath, srcPath } = constants
359-
const nmPath = path.join(rootPath, NODE_MODULES)
360-
const constantsSrcPath = path.join(srcPath, 'constants.mts')
361-
const externalSrcPath = path.join(srcPath, 'external')
362-
const blessedContribSrcPath = path.join(externalSrcPath, BLESSED_CONTRIB)
363-
const shadowNpmBinSrcPath = path.join(srcPath, 'shadow/npm/bin.mts')
364-
const shadowNpmInjectSrcPath = path.join(srcPath, 'shadow/npm/inject.mts')
365-
const utilsSrcPath = path.join(srcPath, UTILS)
360+
const nmPath = normalizePath(path.join(rootPath, NODE_MODULES))
361+
const constantsSrcPath = normalizePath(path.join(srcPath, 'constants.mts'))
362+
const externalSrcPath = normalizePath(path.join(srcPath, 'external'))
363+
const blessedContribSrcPath = normalizePath(
364+
path.join(externalSrcPath, BLESSED_CONTRIB),
365+
)
366+
const shadowNpmBinSrcPath = normalizePath(
367+
path.join(srcPath, 'shadow/npm/bin.mts'),
368+
)
369+
const shadowNpmInjectSrcPath = normalizePath(
370+
path.join(srcPath, 'shadow/npm/inject.mts'),
371+
)
372+
const utilsSrcPath = normalizePath(path.join(srcPath, UTILS))
366373

367374
return [
368375
// Bundle <root>/src/ entry point files and output to <root>/dist/.
@@ -397,7 +404,7 @@ export default async () => {
397404
case shadowNpmInjectSrcPath:
398405
return SHADOW_NPM_INJECT
399406
default:
400-
if (id.startsWith(utilsSrcPath)) {
407+
if (id.startsWith(`${utilsSrcPath}/`)) {
401408
return UTILS
402409
}
403410
if (id.includes(SLASH_NODE_MODULES_SLASH)) {

test/utils.mts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@ export async function invokeNpm(
4141
args: string[],
4242
env = {},
4343
): Promise<{
44-
status: boolean
4544
code: number
45+
error?: {
46+
message: string
47+
stack: string
48+
}
49+
status: boolean
4650
stdout: string
4751
stderr: string
4852
}> {
@@ -74,7 +78,11 @@ export async function invokeNpm(
7478
} catch (e: unknown) {
7579
return {
7680
status: false,
77-
code: e?.['code'],
81+
code: e?.['code'] || 1,
82+
error: {
83+
message: e?.['message'] || '',
84+
stack: e?.['stack'] || '',
85+
},
7886
stdout: toAsciiSafeString(
7987
normalizeLogSymbols(stripAnsi(e?.['stdout']?.trim() ?? '')),
8088
),

0 commit comments

Comments
 (0)