diff --git a/src/config.js b/src/config.js index 4accbef1aa..f48f92a2b4 100644 --- a/src/config.js +++ b/src/config.js @@ -177,7 +177,6 @@ export default class Config { await fs.mkdirp(this.globalFolder); await fs.mkdirp(this.cacheFolder); await fs.mkdirp(this.tempFolder); - await fs.mkdirp(this.linkFolder); this.linkedModules = []; @@ -185,9 +184,13 @@ export default class Config { const maybeLinkedModules = await fs.readdir(this.linkFolder); for (const maybeLinked of maybeLinkedModules) { - // handle scoped modules separately - if (maybeLinked.indexOf('@') === 0) { - const scopedLinked = await fs.readdir(path.join(this.linkFolder, maybeLinked)); + const linkedPath = path.join(this.linkFolder, maybeLinked); + const isScopedName = maybeLinked.indexOf('@') === 0; + const isScopedContainer = isScopedName && !await fs.exists(path.join(linkedPath, 'package.json')); + + // handle scoped containers (npm scoped modules) separately + if (isScopedContainer) { + const scopedLinked = await fs.readdir(linkedPath); this.linkedModules.push(...scopedLinked.map((dir) => path.join(maybeLinked, dir))); } else { this.linkedModules.push(maybeLinked); diff --git a/src/package-linker.js b/src/package-linker.js index 2c7a3d3120..d5accdd2ef 100644 --- a/src/package-linker.js +++ b/src/package-linker.js @@ -159,11 +159,14 @@ export default class PackageLinker { const files = await fs.readdir(loc); for (const file of files) { const filePath = path.join(loc, file); - // scoped packages are a nested one level deeper - if (file.indexOf('@') === 0) { + + const isScopedName = file.indexOf('@') === 0; + const isScopedContainer = isScopedName && !await fs.exists(path.join(loc, 'package.json')); + // npm scoped packages are a nested one level deeper + if (isScopedContainer) { const scopedFiles = await fs.readdir(filePath); - for (const scoped of scopedFiles) { - possibleExtraneous.add(path.join(filePath, scoped)); + for (const scopedFile of scopedFiles) { + possibleExtraneous.add(path.join(filePath, scopedFile)); } } else { possibleExtraneous.add(filePath);