|
5 | 5 | * Use of this source code is governed by an MIT-style license that can be
|
6 | 6 | * found in the LICENSE file at https://angular.io/license
|
7 | 7 | */
|
8 |
| -import * as fs from 'fs'; |
9 |
| -import { join } from 'path'; |
| 8 | + |
| 9 | +import { Path, join } from '@angular-devkit/core'; |
10 | 10 | import * as ts from 'typescript';
|
11 | 11 | import { TypeScriptFileRefactor } from './refactor';
|
12 | 12 |
|
@@ -54,9 +54,10 @@ function _recursiveSymbolExportLookup(refactor: TypeScriptFileRefactor,
|
54 | 54 | for (const specifier of binding.elements) {
|
55 | 55 | if (specifier.name.text == symbolName) {
|
56 | 56 | // If it's a directory, load its index and recursively lookup.
|
57 |
| - if (fs.statSync(module).isDirectory()) { |
58 |
| - const indexModule = join(module, 'index.ts'); |
59 |
| - if (fs.existsSync(indexModule)) { |
| 57 | + // If it's a file it will return false |
| 58 | + if (host.directoryExists && host.directoryExists(module)) { |
| 59 | + const indexModule = join(module as Path, 'index.ts'); |
| 60 | + if (host.fileExists(indexModule)) { |
60 | 61 | const indexRefactor = new TypeScriptFileRefactor(indexModule, host, program);
|
61 | 62 | const maybeModule = _recursiveSymbolExportLookup(
|
62 | 63 | indexRefactor, symbolName, host, program);
|
|
0 commit comments