@@ -9,6 +9,7 @@ import { debugDir } from '@socketsecurity/registry/lib/debug'
99import { readDirNames } from '@socketsecurity/registry/lib/fs'
1010import { logger } from '@socketsecurity/registry/lib/logger'
1111import { readPackageJson } from '@socketsecurity/registry/lib/packages'
12+ import { normalizePath } from '@socketsecurity/registry/lib/path'
1213import { isNonEmptyString } from '@socketsecurity/registry/lib/strings'
1314import { pluralize } from '@socketsecurity/registry/lib/words'
1415
@@ -97,15 +98,15 @@ async function applyNpmPatches(
9798 const dirNames = await readDirNames ( nmPath )
9899 for ( const dirName of dirNames ) {
99100 const isScoped = dirName . startsWith ( '@' )
100- const pkgPath = path . join ( nmPath , dirName )
101+ const pkgPath = normalizePath ( path . join ( nmPath , dirName ) )
101102 const pkgSubNames = isScoped
102103 ? // eslint-disable-next-line no-await-in-loop
103104 await readDirNames ( pkgPath )
104105 : [ dirName ]
105106
106107 for ( const pkgSubName of pkgSubNames ) {
107108 const dirFullName = isScoped ? `${ dirName } /${ pkgSubName } ` : pkgSubName
108- const pkgPath = path . join ( nmPath , dirFullName )
109+ const pkgPath = normalizePath ( path . join ( nmPath , dirFullName ) )
109110 // eslint-disable-next-line no-await-in-loop
110111 const pkgJson = await readPackageJson ( pkgPath , { throws : false } )
111112 if (
@@ -247,7 +248,7 @@ async function processFilePatch(
247248
248249 spinner ?. stop ( )
249250
250- const filepath = path . join ( pkgPath , fileName )
251+ const filepath = normalizePath ( path . join ( pkgPath , fileName ) )
251252 if ( ! existsSync ( filepath ) ) {
252253 logger . log ( `File not found: ${ fileName } ` )
253254 if ( wasSpinning ) {
@@ -307,7 +308,9 @@ async function processFilePatch(
307308 return false
308309 }
309310
310- const blobPath = path . join ( socketDir , 'blobs' , fileInfo . afterHash )
311+ const blobPath = normalizePath (
312+ path . join ( socketDir , 'blobs' , fileInfo . afterHash ) ,
313+ )
311314 if ( ! existsSync ( blobPath ) ) {
312315 logger . fail ( `Error: Patch file not found at ${ blobPath } ` )
313316 logger . groupEnd ( )
@@ -373,8 +376,10 @@ export async function handlePatch({
373376 spinner,
374377} : HandlePatchConfig ) : Promise < void > {
375378 try {
376- const dotSocketDirPath = path . join ( cwd , DOT_SOCKET_DIR )
377- const manifestPath = path . join ( dotSocketDirPath , MANIFEST_JSON )
379+ const dotSocketDirPath = normalizePath ( path . join ( cwd , DOT_SOCKET_DIR ) )
380+ const manifestPath = normalizePath (
381+ path . join ( dotSocketDirPath , MANIFEST_JSON ) ,
382+ )
378383 const manifestContent = await fs . readFile ( manifestPath , UTF8 )
379384 const manifestData = JSON . parse ( manifestContent )
380385 const purls = purlObjs . map ( String )
0 commit comments