@@ -25,8 +25,17 @@ const isWindows = platform === 'win32';
2525
2626function maybeWindowsPath ( path ) {
2727 if ( ! path ) return path ;
28- if ( ! isWindows ) return resolve ( path ) ;
29- return '//?/' + resolve ( path ) . replace ( / \\ / g, '/' ) ;
28+ const resolvedPath = resolve ( path ) ;
29+ if ( ! isWindows ) return resolvedPath ;
30+
31+ // Strip any existing UNC prefix check both the format we add as well as what
32+ // the windows API returns when using path.resolve
33+ let cleanPath = resolvedPath ;
34+ while ( cleanPath . startsWith ( '\\\\?\\' ) || cleanPath . startsWith ( '//?/' ) ) {
35+ cleanPath = cleanPath . substring ( 4 ) ;
36+ }
37+
38+ return '//?/' + cleanPath . replace ( / \\ / g, '/' ) ;
3039}
3140
3241/**
@@ -108,7 +117,7 @@ export async function componentize(opts,
108117 . slice ( 0 , 12 )
109118 ) ;
110119 await mkdir ( tmpDir ) ;
111- const sourceDir = join ( tmpDir , 'sources' ) ;
120+ const sourceDir = maybeWindowsPath ( join ( tmpDir , 'sources' ) ) ;
112121 await mkdir ( sourceDir ) ;
113122
114123 let {
@@ -223,7 +232,7 @@ export async function componentize(opts,
223232 console . log ( env ) ;
224233 }
225234
226- let initializerPath = join ( sourceDir , 'initializer.js' ) ;
235+ let initializerPath = maybeWindowsPath ( join ( sourceDir , 'initializer.js' ) ) ;
227236 sourcePath = maybeWindowsPath ( sourcePath ) ;
228237 let workspacePrefix = dirname ( sourcePath ) ;
229238
0 commit comments