Просмотр исходного кода

Merge branch 'dev/7.0.x' into fix/155911-editor-occurs-unstable-behavior

Yuki Takei 1 год назад
Родитель
Сommit
0454493488
1 измененных файлов с 14 добавлено и 8 удалено
  1. 14 8
      apps/app/src/utils/next.config.utils.js

+ 14 - 8
apps/app/src/utils/next.config.utils.js

@@ -25,14 +25,17 @@ exports.listScopedPackages = (scopes, opts = defaultOpts) => {
       fs.readdirSync(path.resolve(nodeModulesPath, scope))
       fs.readdirSync(path.resolve(nodeModulesPath, scope))
         .filter(name => !name.startsWith('.'))
         .filter(name => !name.startsWith('.'))
         .forEach((folderName) => {
         .forEach((folderName) => {
-          const { name } = require(path.resolve(
+          const packageJsonPath = path.resolve(
             nodeModulesPath,
             nodeModulesPath,
             scope,
             scope,
             folderName,
             folderName,
             'package.json',
             'package.json',
-          ));
-          if (!opts.ignorePackageNames.includes(name)) {
-            scopedPackages.push(name);
+          );
+          if (fs.existsSync(packageJsonPath)) {
+            const { name } = require(packageJsonPath);
+            if (!opts.ignorePackageNames.includes(name)) {
+              scopedPackages.push(name);
+            }
           }
           }
         });
         });
     });
     });
@@ -51,13 +54,16 @@ exports.listPrefixedPackages = (prefixes, opts = defaultOpts) => {
     .filter(name => prefixes.some(prefix => name.startsWith(prefix)))
     .filter(name => prefixes.some(prefix => name.startsWith(prefix)))
     .filter(name => !name.startsWith('.'))
     .filter(name => !name.startsWith('.'))
     .forEach((folderName) => {
     .forEach((folderName) => {
-      const { name } = require(path.resolve(
+      const packageJsonPath = path.resolve(
         nodeModulesPath,
         nodeModulesPath,
         folderName,
         folderName,
         'package.json',
         'package.json',
-      ));
-      if (!opts.ignorePackageNames.includes(name)) {
-        prefixedPackages.push(name);
+      );
+      if (fs.existsSync(packageJsonPath)) {
+        const { name } = require(packageJsonPath);
+        if (!opts.ignorePackageNames.includes(name)) {
+          prefixedPackages.push(name);
+        }
       }
       }
     });
     });