Skip to content

Commit 10e56d4

Browse files
authored
fix: skip file not exits (#62)
1 parent 7c6cb45 commit 10e56d4

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

core/common-util/src/ModuleConfig.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,13 @@ export class ModuleConfigUtil {
106106
const moduleDirSet = new Set<string>();
107107
for (const packagePath of packagePaths) {
108108
const absolutePkgPath = path.join(baseDir, packagePath);
109-
const realPkgPath = fs.realpathSync(absolutePkgPath);
109+
let realPkgPath;
110+
try {
111+
realPkgPath = fs.realpathSync(absolutePkgPath);
112+
} catch (_) {
113+
continue;
114+
}
115+
110116
const moduleDir = path.dirname(realPkgPath);
111117

112118
// skip the symbolic link
@@ -141,7 +147,12 @@ export class ModuleConfigUtil {
141147

142148
private static readModuleFromNodeModules(baseDir: string) {
143149
const ref: ModuleReference[] = [];
144-
const pkgContent = fs.readFileSync(path.join(baseDir, 'package.json'), 'utf8');
150+
let pkgContent: string;
151+
try {
152+
pkgContent = fs.readFileSync(path.join(baseDir, 'package.json'), 'utf8');
153+
} catch (_) {
154+
return [];
155+
}
145156
const pkg = JSON.parse(pkgContent);
146157
if (!fs.existsSync(path.join(baseDir, '/node_modules'))) {
147158
return ref;

0 commit comments

Comments
 (0)