File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ) ;
You can’t perform that action at this time.
0 commit comments