Skip to content

Commit

Permalink
fix: ensure glob finds all files in folders
Browse files Browse the repository at this point in the history
For some reason {folders.value.join(',')} as part of the glob doesn't work and returns less files
fixes #10228
  • Loading branch information
dummdidumm committed Jun 23, 2023
1 parent 556b832 commit 73a4371
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/flat-berries-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte-migrate': patch
---

fix: ensure glob finds all files in folders
10 changes: 7 additions & 3 deletions packages/migrate/migrations/svelte-4/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,13 @@ export async function migrate() {
'.svelte'
];
const extensions = [...svelte_extensions, '.ts', '.js'];
const files = glob(`{${folders.value.join(',')}}/**`, { filesOnly: true, dot: true })
.map((file) => file.replace(/\\/g, '/'))
.filter((file) => !file.includes('/node_modules/'));
// For some reason {folders.value.join(',')} as part of the glob doesn't work and returns less files
const files = folders.value.flatMap(
/** @param {string} folder */ (folder) =>
glob(`${folder}/**`, { filesOnly: true, dot: true })
.map((file) => file.replace(/\\/g, '/'))
.filter((file) => !file.includes('/node_modules/'))
);

for (const file of files) {
if (extensions.some((ext) => file.endsWith(ext))) {
Expand Down

0 comments on commit 73a4371

Please sign in to comment.