Skip to content

Commit 95fc972

Browse files
committed
Fix relative path on Linux
1 parent a2f2ffd commit 95fc972

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

scripts/lint/utils.cjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"use strict";
99

1010
const path = require("node:path");
11+
const { fileURLToPath } = require("node:url");
1112

1213
/**
1314
* ANSI colors.
@@ -116,7 +117,9 @@ exports.pluralize = function (word, count) {
116117
* @returns Relative file path.
117118
*/
118119
exports.toRelativePath = function (filePath, root) {
119-
const uri = filePath.replace("file:///", "");
120+
const uri = filePath.startsWith("file:///")
121+
? fileURLToPath(filePath)
122+
: filePath;
120123
const rel = path.relative(root, uri);
121124
if (rel.startsWith("..")) return uri;
122125
return "." + path.sep + rel;

0 commit comments

Comments
 (0)