Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.2][bug] Codemirror duplicated assets entries #44674

Open
wants to merge 15 commits into
base: 5.2-dev
Choose a base branch
from
20 changes: 10 additions & 10 deletions build/build-modules-js/init/common/resolve-package.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ const { existsSync, readdirSync } = require('fs-extra');
*/
module.exports.resolvePackageFile = (relativePath) => {
for (let i = 0, l = module.paths.length; i < l; i += 1) {
const path = module.paths[i];
const fullPath = `${path}/${relativePath}`;
if (existsSync(fullPath)) {
return fullPath;
}
}
const path = module.paths[i];
const fullPath = `${path}/${relativePath}`;
if (existsSync(fullPath)) {
return fullPath;
}
}
richard67 marked this conversation as resolved.
Show resolved Hide resolved

return false;
return false;
};

/**
Expand All @@ -27,7 +27,7 @@ module.exports.resolvePackageFile = (relativePath) => {
* @returns {[]}
*/
module.exports.getPackagesUnderScope = (scope) => {
const cmModules = [];
const cmModules = new Set();

// Get the scope roots
const roots = [];
Expand All @@ -41,9 +41,9 @@ module.exports.getPackagesUnderScope = (scope) => {
// List of modules
roots.forEach((rootPath) => {
readdirSync(rootPath).forEach((subModule) => {
cmModules.push(`${scope}/${subModule}`);
cmModules.add(`${scope}/${subModule}`);
});
});

return cmModules;
return [...cmModules];
};