Skip to content

Commit 7f55cdb

Browse files
Simplify changedPackages logic
1 parent 5a38d88 commit 7f55cdb

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

scripts/publish.mjs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,14 @@ async function run() {
167167
/** Uses packages and changedFiles to determine which packages have changed */
168168
const changedPackages = RELEASE_ALL
169169
? packages
170-
: changedFiles.reduce((acc, file) => {
171-
const pkg = packages.find(
172-
(p) =>
173-
file.startsWith(path.join(p.packageDir, 'src')) ||
174-
file.startsWith(path.join(p.packageDir, 'package.json')),
170+
: packages.filter((pkg) => {
171+
const changed = changedFiles.some(
172+
(file) =>
173+
file.startsWith(path.join(pkg.packageDir, 'src')) ||
174+
file.startsWith(path.join(pkg.packageDir, 'package.json')),
175175
)
176-
if (pkg && !acc.find((d) => d.name === pkg.name)) {
177-
acc.push(pkg)
178-
}
179-
return acc
180-
}, /** @type {import('./types').Package[]} */ ([]))
176+
return changed
177+
})
181178

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

0 commit comments

Comments
 (0)