Skip to content

Commit

Permalink
Merge pull request #88 from cerebral/fixPackagesGlob
Browse files Browse the repository at this point in the history
fix(packages): fix bug where "packages/node_modules" would be seen as a package
  • Loading branch information
maia-tae authored Mar 23, 2021
2 parents e5884c2 + ffc3b14 commit e791981
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/helpers/getPackagesPaths.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import globby from 'globby'
import { readFileSync } from 'fs'
import { existsSync, readFileSync } from 'fs'
import { resolve } from '../helpers/path'

export function getPackagesPaths(cwd, glob) {
Expand All @@ -13,6 +13,8 @@ export function getPackagesPaths(cwd, glob) {
return globby
.sync(typeof glob === 'string' ? [glob] : glob, { cwd })
.sort()
.map(path => resolve(cwd, path))
.filter(path => existsSync(resolve(path, 'package.json')))
.reduce((packagesMap, path) => {
const pathArray = path.split('/')
const packageName = pathArray.pop()
Expand All @@ -21,7 +23,7 @@ export function getPackagesPaths(cwd, glob) {
// If package starts with scoped dir, use that as part of name
packagesMap[
dir[0] === '@' ? dir + '/' + packageName : packageName
] = resolve(cwd, path)
] = path

return packagesMap
}, {})
Expand Down

0 comments on commit e791981

Please sign in to comment.