Handle Windows absolute paths in resolveUriToFile
This commit is contained in:
parent
c2fd5d10f6
commit
130a51dbc6
9 changed files with 25 additions and 11 deletions
|
|
@ -55,7 +55,10 @@ export function includeAndExcludeAnalysisPaths(config: configUtils.Config) {
|
|||
// If the temporary or tools directory is in the working directory ignore that too.
|
||||
const tempRelativeToWorking = path.relative(process.cwd(), config.tempDir);
|
||||
let pathsIgnore = config.pathsIgnore;
|
||||
if (!tempRelativeToWorking.startsWith("..")) {
|
||||
if (
|
||||
!tempRelativeToWorking.startsWith("..") &&
|
||||
!path.isAbsolute(tempRelativeToWorking)
|
||||
) {
|
||||
pathsIgnore = pathsIgnore.concat(tempRelativeToWorking);
|
||||
}
|
||||
if (pathsIgnore.length !== 0) {
|
||||
|
|
|
|||
|
|
@ -150,9 +150,16 @@ test("resolveUriToFile", (t) => {
|
|||
t.is(testResolveUriToFile(`file://${filepath}`, undefined, []), filepath);
|
||||
|
||||
// Relative paths are made absolute
|
||||
t.is(testResolveUriToFile(relativeFilepath, undefined, []), filepath);
|
||||
t.is(
|
||||
testResolveUriToFile(`file://${relativeFilepath}`, undefined, []),
|
||||
testResolveUriToFile(relativeFilepath, undefined, [])
|
||||
?.split(path.sep)
|
||||
.join("/"),
|
||||
filepath
|
||||
);
|
||||
t.is(
|
||||
testResolveUriToFile(`file://${relativeFilepath}`, undefined, [])
|
||||
?.split(path.sep)
|
||||
.join("/"),
|
||||
filepath
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import * as fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
import Long from "long";
|
||||
|
||||
|
|
@ -226,7 +227,7 @@ export function resolveUriToFile(
|
|||
// Just assume a relative path is relative to the src root.
|
||||
// This is not necessarily true but should be a good approximation
|
||||
// and here we likely want to err on the side of handling more cases.
|
||||
if (!uri.startsWith("/")) {
|
||||
if (!path.isAbsolute(uri)) {
|
||||
uri = srcRootPrefix + uri;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue