Skip to content

Commit 8184cf1

Browse files
committed
fix bug for file paths in windows during componentization
Signed-off-by: karthik2804 <karthik.ganeshram@fermyon.com>
1 parent 246e4da commit 8184cf1

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ jobs:
132132
########
133133

134134
test:
135-
runs-on: ubuntu-latest
135+
runs-on: ${{ matrix.os }}
136136
needs:
137137
- build
138138
strategy:
@@ -141,6 +141,9 @@ jobs:
141141
node-version:
142142
- '23.10.0'
143143
# - latest reenable when https://github.com/nodejs/node/issues/57172 is fixed
144+
os:
145+
- ubuntu-latest
146+
- windows-latest
144147
build-type:
145148
- 'release'
146149
- 'debug'

src/componentize.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,17 @@ const isWindows = platform === 'win32';
2525

2626
function 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

Comments
 (0)