(file: File)
| 927 | } |
| 928 | |
| 929 | private getSourcePath(file: File) { |
| 930 | let sourcePath = file.sourcePath; |
| 931 | if (sourcePath) { |
| 932 | if (pathIsAbsolute(sourcePath)) { |
| 933 | let relPath: string | undefined; |
| 934 | try { |
| 935 | relPath = pathRelative(this.sourceRoot, sourcePath); |
| 936 | } finally { |
| 937 | if (! relPath || relPath.startsWith("..")) { |
| 938 | if (this.resolver.joinAndStat(this.sourceRoot, sourcePath)) { |
| 939 | // If sourcePath exists as a path relative to this.sourceRoot, |
| 940 | // strip away the leading / that made it look absolute. |
| 941 | return pathNormalize(pathJoin(".", sourcePath)); |
| 942 | } |
| 943 | |
| 944 | if (relPath) { |
| 945 | throw new Error("sourcePath outside sourceRoot: " + sourcePath); |
| 946 | } |
| 947 | |
| 948 | // If pathRelative threw an exception above, and we were not |
| 949 | // able to handle the problem, it will continue propagating |
| 950 | // from this finally block. |
| 951 | } |
| 952 | } |
| 953 | |
| 954 | sourcePath = relPath; |
| 955 | } |
| 956 | |
| 957 | } else if (file.servePath) { |
| 958 | sourcePath = convertToOSPath(file.servePath.replace(/^\//, "")); |
| 959 | |
| 960 | } else if ((file as any).path) { |
| 961 | sourcePath = (file as any).path; |
| 962 | } |
| 963 | |
| 964 | return pathNormalize(pathJoin(".", sourcePath)); |
| 965 | } |
| 966 | |
| 967 | private findImportedModuleIdentifiers( |
| 968 | file: File, |
no test coverage detected