8
8
} from '@bytecodealliance/jco' ;
9
9
import { spawnSync } from 'node:child_process' ;
10
10
import { tmpdir } from 'node:os' ;
11
- import { resolve , join , dirname } from 'node:path' ;
11
+ import { join , dirname } from 'node:path' ;
12
12
import { readFile , writeFile , mkdir , rm } from 'node:fs/promises' ;
13
13
import { rmSync , existsSync } from 'node:fs' ;
14
14
import { createHash } from 'node:crypto' ;
@@ -17,26 +17,13 @@ import {
17
17
stubWasi ,
18
18
} from '../lib/spidermonkey-embedding-splicer.js' ;
19
19
import { fileURLToPath } from 'node:url' ;
20
- import { cwd , stdout , platform } from 'node:process' ;
20
+ import { cwd , stdout } from 'node:process' ;
21
+
22
+ import { maybeWindowsPath } from './platform.js' ;
23
+
21
24
export const { version } = JSON . parse (
22
25
await readFile ( new URL ( '../package.json' , import . meta. url ) , 'utf8' ) ,
23
26
) ;
24
- const isWindows = platform === 'win32' ;
25
-
26
- function maybeWindowsPath ( path ) {
27
- if ( ! path ) return path ;
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, '/' ) ;
39
- }
40
27
41
28
/**
42
29
* Clean up the given input string by removing the given patterns if
0 commit comments