Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(filter-workspace-packages): filter not working if the path contains Korean characters #4595

Merged
merged 2 commits into from Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/funny-mirrors-act.md
@@ -0,0 +1,5 @@
---
"@pnpm/filter-workspace-packages": patch
---

'filter-workspace-packages' will filter the package well even if Korean is included in the path. fix #4594
Expand Up @@ -64,6 +64,8 @@ async function getChangedDirsSinceCommit (commit: string, workingDir: string, te
}

const allChangedFiles = diff.split('\n')
// The prefix and suffix '"' are appended to the Korean path
.map(line => line.replace(/^"/, '').replace(/"$/, ''))
const patterns = changedFilesIgnorePattern.filter(
(pattern) => pattern.length
)
Expand Down
19 changes: 17 additions & 2 deletions packages/filter-workspace-packages/test/index.ts
Expand Up @@ -366,6 +366,11 @@ test('select changed packages', async () => {

await mkdir(pkg3Dir)

const pkgKorDir = path.join(workspaceDir, 'package-kor')

await mkdir(pkgKorDir)
await touch(path.join(pkgKorDir, 'fileKor한글.js'))

await execa('git', ['add', '.'], { cwd: workspaceDir })
await execa('git', ['commit', '--allow-empty-message', '-m', '', '--no-gpg-sign'], { cwd: workspaceDir })

Expand Down Expand Up @@ -412,6 +417,16 @@ test('select changed packages', async () => {
},
},
},
[pkgKorDir]: {
dependencies: [],
package: {
dir: pkgKorDir,
manifest: {
name: 'package-kor',
version: '0.0.0',
},
},
},
[pkg20Dir]: {
dependencies: [],
package: {
Expand All @@ -429,7 +444,7 @@ test('select changed packages', async () => {
diff: 'HEAD~1',
}], { workspaceDir })

expect(Object.keys(selectedProjectsGraph)).toStrictEqual([pkg1Dir, pkg2Dir])
expect(Object.keys(selectedProjectsGraph)).toStrictEqual([pkg1Dir, pkg2Dir, pkgKorDir])
}
{
const { selectedProjectsGraph } = await filterWorkspacePackages(pkgsGraph, [{
Expand All @@ -453,7 +468,7 @@ test('select changed packages', async () => {
includeDependents: true,
}], { workspaceDir, testPattern: ['*/file2.js'] })

expect(Object.keys(selectedProjectsGraph)).toStrictEqual([pkg1Dir, pkg2Dir])
expect(Object.keys(selectedProjectsGraph)).toStrictEqual([pkg1Dir, pkgKorDir, pkg2Dir])
}
})

Expand Down