Skip to content

Commit

Permalink
Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit0 committed Apr 16, 2023
1 parent 28c7bc1 commit d773ecb
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
14 changes: 12 additions & 2 deletions src/lib/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import { Converter } from "./converter/index";
import { Renderer } from "./output/renderer";
import { Deserializer, JSONOutput, Serializer } from "./serialization";
import type { ProjectReflection } from "./models/index";
import { Logger, ConsoleLogger, loadPlugins, writeFile, normalizePath } from "./utils/index";
import {
Logger,
ConsoleLogger,
loadPlugins,
writeFile,
normalizePath,
} from "./utils/index";

import {
AbstractComponent,
Expand Down Expand Up @@ -585,7 +591,11 @@ export class Application extends ChildableComponent<
const start = Date.now();

const rootDir = deriveRootDir(this.entryPoints);
this.logger.verbose(`Derived root dir is ${rootDir}, will expand ${this.entryPoints.map(normalizePath).join(", ")}`)
this.logger.verbose(
`Derived root dir is ${rootDir}, will expand ${this.entryPoints
.map(normalizePath)
.join(", ")}`
);
const entryPoints = this.entryPoints.flatMap((entry) =>
glob(entry, rootDir)
);
Expand Down
14 changes: 9 additions & 5 deletions src/lib/models/reflections/ReflectionSymbolId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export class ReflectionSymbolId {
) {
if ("name" in symbol) {
declaration ??= symbol?.declarations?.[0];
this.fileName = normalizePath(declaration?.getSourceFile().fileName ?? "\0");
this.fileName = normalizePath(
declaration?.getSourceFile().fileName ?? "\0"
);
if (symbol.declarations?.some(ts.isSourceFile)) {
this.qualifiedName = "";
} else {
Expand All @@ -61,10 +63,12 @@ export class ReflectionSymbolId {
toObject(serializer: Serializer) {
return {
sourceFileName: isAbsolute(this.fileName)
? normalizePath(relative(
serializer.projectRoot,
resolveDeclarationMaps(this.fileName)
))
? normalizePath(
relative(
serializer.projectRoot,
resolveDeclarationMaps(this.fileName)
)
)
: this.fileName,
qualifiedName: this.qualifiedName,
};
Expand Down
9 changes: 6 additions & 3 deletions src/lib/utils/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,19 @@ export function isDir(path: string) {
}

export function deriveRootDir(globPaths: string[]): string {
const normalized = globPaths.map(normalizePath)
const normalized = globPaths.map(normalizePath);
const globs = createMinimatch(normalized);
const rootPaths = globs.flatMap((glob, i) =>
filterMap(glob.set, (set) => {
const stop = set.findIndex((part) => typeof part !== "string");
if (stop === -1) {
return normalized[i];
} else {
const kept = set.slice(0, stop).join('/')
return normalized[i].substring(0, normalized[i].indexOf(kept) + kept.length);
const kept = set.slice(0, stop).join("/");
return normalized[i].substring(
0,
normalized[i].indexOf(kept) + kept.length
);
}
})
);
Expand Down
2 changes: 1 addition & 1 deletion src/test/merge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("Merging projects", () => {
app.logger = logger;

const project = app.convert();
logger.expectNoOtherMessages()
logger.expectNoOtherMessages();

equal(project?.name, "typedoc");
equal(
Expand Down

0 comments on commit d773ecb

Please sign in to comment.