Skip to content

Commit

Permalink
fix: handle invalid workspace entries (#1316)
Browse files Browse the repository at this point in the history
Test that workspace entries are directories and have package.json
files before processing them.
  • Loading branch information
achingbrain committed Jun 27, 2023
1 parent 369453f commit a95aec3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/check-project/index.js
Expand Up @@ -113,7 +113,19 @@ async function processMonorepo (projectDir, manifest, branchName, repoUrl) {
cwd: projectDir,
absolute: true
})) {
const pkg = fs.readJSONSync(path.join(subProjectDir, 'package.json'))
const stat = await fs.stat(subProjectDir)

if (!stat.isDirectory()) {
continue
}

const manfest = path.join(subProjectDir, 'package.json')

if (!fs.existsSync(manfest)) {
continue
}

const pkg = fs.readJSONSync(manfest)
const homePage = `${repoUrl}/tree/master${subProjectDir.substring(projectDir.length)}`

console.info('Found monorepo project', pkg.name)
Expand Down
14 changes: 13 additions & 1 deletion src/utils.js
Expand Up @@ -371,7 +371,19 @@ async function parseProjects (projectDir, workspaces) {
cwd: projectDir,
absolute: true
})) {
const pkg = fs.readJSONSync(path.join(subProjectDir, 'package.json'))
const stat = await fs.stat(subProjectDir)

if (!stat.isDirectory()) {
continue
}

const manfest = path.join(subProjectDir, 'package.json')

if (!fs.existsSync(manfest)) {
continue
}

const pkg = fs.readJSONSync(manfest)

projects[pkg.name] = {
manifest: pkg,
Expand Down

0 comments on commit a95aec3

Please sign in to comment.