Skip to content

Commit

Permalink
Simplify changedPackages logic
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlancollins committed Jun 2, 2023
1 parent 5a38d88 commit 7f55cdb
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions scripts/publish.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,14 @@ async function run() {
/** Uses packages and changedFiles to determine which packages have changed */
const changedPackages = RELEASE_ALL
? packages
: changedFiles.reduce((acc, file) => {
const pkg = packages.find(
(p) =>
file.startsWith(path.join(p.packageDir, 'src')) ||
file.startsWith(path.join(p.packageDir, 'package.json')),
: packages.filter((pkg) => {
const changed = changedFiles.some(
(file) =>
file.startsWith(path.join(pkg.packageDir, 'src')) ||
file.startsWith(path.join(pkg.packageDir, 'package.json')),
)
if (pkg && !acc.find((d) => d.name === pkg.name)) {
acc.push(pkg)
}
return acc
}, /** @type {import('./types').Package[]} */ ([]))
return changed
})

// If a package has a dependency that has been updated, we need to update the
// package that depends on it as well.
Expand Down

0 comments on commit 7f55cdb

Please sign in to comment.