Skip to content

Commit 852b90a

Browse files
committed
TS: Be compatible with odasa/qltest
1 parent dc30dcf commit 852b90a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

javascript/extractor/lib/typescript/src/virtual_source_root.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ export class VirtualSourceRoot {
88
constructor(
99
private sourceRoot: string,
1010

11-
/** Directory whose folder structure mirrors the real source root, but with `node_modules` installed. */
11+
/**
12+
* Directory whose folder structure mirrors the real source root, but with `node_modules` installed,
13+
* or undefined if no virtual source root exists.
14+
*/
1215
private virtualSourceRoot: string,
1316
) {}
1417

1518
/**
1619
* Maps a path under the real source root to the corresonding path in the virtual source root.
1720
*/
1821
public toVirtualPath(path: string) {
22+
if (!this.virtualSourceRoot) return null;
1923
let relative = pathlib.relative(this.sourceRoot, path);
2024
if (relative.startsWith('..') || pathlib.isAbsolute(relative)) return null;
2125
return pathlib.join(this.virtualSourceRoot, relative);

0 commit comments

Comments
 (0)