Skip to content

Commit

Permalink
Check that @ prefixed folder is a container
Browse files Browse the repository at this point in the history
  • Loading branch information
tgriesser committed Nov 21, 2016
1 parent 1eff8fd commit 28c9869
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 7 additions & 4 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,20 @@ 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 = [];

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);
Expand Down
11 changes: 7 additions & 4 deletions src/package-linker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 28c9869

Please sign in to comment.