Skip to content

Commit

Permalink
Normalize all paths on Windows
Browse files Browse the repository at this point in the history
Fixes #2113

Co-Authored-By: @royaltm
  • Loading branch information
Gerrit0 committed Dec 11, 2022
1 parent 8a3e195 commit 36c95c0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Unreleased

### Bug Fixes

- Normalize all file paths on Windows, #2113.

## v0.23.21 (2022-11-14)

### Features
Expand Down
5 changes: 3 additions & 2 deletions src/lib/converter/plugins/SourcePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { getCommonDirectory, normalizePath } from "../../utils/fs";
import { dirname, relative } from "path";
import { SourceReference } from "../../models";
import { gitIsInstalled, Repository } from "../utils/repository";
import { BasePath } from "../utils/base-path";

/**
* A handler that attaches source file information to reflections.
Expand Down Expand Up @@ -77,7 +78,7 @@ export class SourcePlugin extends ConverterComponent {
const symbol = reflection.project.getSymbolFromReflection(reflection);
for (const node of symbol?.declarations || []) {
const sourceFile = node.getSourceFile();
const fileName = sourceFile.fileName;
const fileName = BasePath.normalize(sourceFile.fileName);
this.fileNames.add(fileName);

let position: ts.LineAndCharacter;
Expand Down Expand Up @@ -115,7 +116,7 @@ export class SourcePlugin extends ConverterComponent {
if (this.disableSources || !sig) return;

const sourceFile = sig.getSourceFile();
const fileName = sourceFile.fileName;
const fileName = BasePath.normalize(sourceFile.fileName);
this.fileNames.add(fileName);

const position = ts.getLineAndCharacterOfPosition(
Expand Down
2 changes: 1 addition & 1 deletion src/lib/converter/utils/base-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class BasePath {
// Remove all surrounding quotes
path = path.replace(/^["']+|["']+$/g, "");

// Make Windows drive letters lower case
// Make Windows drive letters upper case
return path.replace(/^([^:]+):\//, (_m, m1) => m1.toUpperCase() + ":/");
}
}

0 comments on commit 36c95c0

Please sign in to comment.