Merge pull request #11494 from webpack/bugfix/yarn-2

avoid error for managed paths that only contain a node_modules
This commit is contained in:
Tobias Koppers 2020-09-17 20:28:56 +02:00 committed by GitHub
commit 1fb44c6952
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 3 deletions

View File

@ -2658,9 +2658,22 @@ class FileSystemInfo {
if (err) {
if (err.code === "ENOENT" || err.code === "ENOTDIR") {
// no package.json or path is not a directory
const problem = `Managed item ${path} isn't a directory or doesn't contain a package.json`;
this.logger.warn(problem);
return callback(new Error(problem));
this.fs.readdir(path, (err, elements) => {
if (
!err &&
elements.length === 1 &&
elements[0] === "node_modules"
) {
// This is only a grouping folder e. g. used by yarn
// we are only interested in existence of this special directory
this._managedItems.set(path, "nested");
return callback(null, "nested");
}
const problem = `Managed item ${path} isn't a directory or doesn't contain a package.json`;
this.logger.warn(problem);
return callback(new Error(problem));
});
return;
}
return callback(err);
}