Skip to content

Commit a8b1c8b

Browse files
committed
Remove the leading slash in windows file path when instrumenting js files for ccov
1 parent 62054ae commit a8b1c8b

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

test/webserver.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,15 @@ class WebServer {
306306

307307
// Transform with Babel and istanbul plugin
308308
const result = babel.transformSync(content, {
309-
filename: fileURL.pathname,
309+
// On Windows, the file URL starts with a slash (e.g.
310+
// /C:/path/to/file.js).
311+
// This leading slash makes the file path invalid and causes the
312+
// instrumentation to fail, so we need to remove it before passing the
313+
// path.
314+
filename:
315+
process.platform === "win32"
316+
? fileURL.pathname.substring(1)
317+
: fileURL.pathname,
310318
plugins: ["babel-plugin-istanbul"],
311319
sourceMaps: false,
312320
});

0 commit comments

Comments
 (0)