Skip to content

Commit 849d521

Browse files
committed
Fix failing tests on Windows
1 parent 0270665 commit 849d521

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

src/lib/application.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Converter } from "./converter/index";
55
import { Renderer } from "./output/renderer";
66
import { Deserializer, JSONOutput, Serializer } from "./serialization";
77
import type { ProjectReflection } from "./models/index";
8-
import { Logger, ConsoleLogger, loadPlugins, writeFile } from "./utils/index";
8+
import { Logger, ConsoleLogger, loadPlugins, writeFile, normalizePath } from "./utils/index";
99

1010
import {
1111
AbstractComponent,
@@ -585,6 +585,7 @@ export class Application extends ChildableComponent<
585585
const start = Date.now();
586586

587587
const rootDir = deriveRootDir(this.entryPoints);
588+
this.logger.verbose(`Derived root dir is ${rootDir}, will expand ${this.entryPoints.map(normalizePath).join(", ")}`)
588589
const entryPoints = this.entryPoints.flatMap((entry) =>
589590
glob(entry, rootDir)
590591
);

src/lib/models/reflections/ReflectionSymbolId.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { JSONOutput, Serializer } from "../../serialization/index";
55
import { readFile } from "../../utils/fs";
66
import { getQualifiedName } from "../../utils/tsutils";
77
import { optional, validate } from "../../utils/validation";
8+
import { normalizePath } from "../../utils";
89

910
/**
1011
* See {@link ReflectionSymbolId}
@@ -35,7 +36,7 @@ export class ReflectionSymbolId {
3536
) {
3637
if ("name" in symbol) {
3738
declaration ??= symbol?.declarations?.[0];
38-
this.fileName = declaration?.getSourceFile().fileName ?? "\0";
39+
this.fileName = normalizePath(declaration?.getSourceFile().fileName ?? "\0");
3940
if (symbol.declarations?.some(ts.isSourceFile)) {
4041
this.qualifiedName = "";
4142
} else {
@@ -60,10 +61,10 @@ export class ReflectionSymbolId {
6061
toObject(serializer: Serializer) {
6162
return {
6263
sourceFileName: isAbsolute(this.fileName)
63-
? relative(
64+
? normalizePath(relative(
6465
serializer.projectRoot,
6566
resolveDeclarationMaps(this.fileName)
66-
)
67+
))
6768
: this.fileName,
6869
qualifiedName: this.qualifiedName,
6970
};

src/lib/utils/fs.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,17 @@ export function isDir(path: string) {
2323
}
2424

2525
export function deriveRootDir(globPaths: string[]): string {
26-
const globs = createMinimatch(globPaths);
27-
const rootPaths = globs.flatMap((glob) =>
26+
const normalized = globPaths.map(normalizePath)
27+
const globs = createMinimatch(normalized);
28+
const rootPaths = globs.flatMap((glob, i) =>
2829
filterMap(glob.set, (set) => {
2930
const stop = set.findIndex((part) => typeof part !== "string");
30-
const path = stop === -1 ? set : set.slice(0, stop);
31-
return `/${path.join("/").replace(/^\//, "")}`;
31+
if (stop === -1) {
32+
return normalized[i];
33+
} else {
34+
const kept = set.slice(0, stop).join('/')
35+
return normalized[i].substring(0, normalized[i].indexOf(kept) + kept.length);
36+
}
3237
})
3338
);
3439
return getCommonDirectory(rootPaths);

src/test/merge.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ describe("Merging projects", () => {
1818
entryPointStrategy: EntryPointStrategy.Merge,
1919
entryPoints: [
2020
join(base, "alias/specs.json"),
21-
join(base, "class/specs.json"),
21+
join(base, "class/*specs.json"),
2222
],
2323
});
24-
app.logger = new TestLogger();
24+
const logger = new TestLogger();
25+
app.logger = logger;
2526

2627
const project = app.convert();
28+
logger.expectNoOtherMessages()
29+
2730
equal(project?.name, "typedoc");
2831
equal(
2932
project.children?.map((c) => c.name),

src/test/utils/options/readers/package-json.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe("Options - PackageJsonReader", () => {
2626
test: (logger: TestLogger) => void
2727
): void {
2828
it(testTitle, () => {
29-
const proj = project(testTitle.replace(/ /g, "_"));
29+
const proj = project(testTitle.replace(/[ "]/g, "_"));
3030
proj.addFile("package.json", pkgJsonContent);
3131
proj.write();
3232

0 commit comments

Comments
 (0)