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

This commit is contained in:
장지훈
2022-04-20 22:05:49 +09:00
committed by GitHub
parent 4170eada79
commit 9f06162824
3 changed files with 24 additions and 2 deletions

View File

@@ -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

View File

@@ -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
)

View File

@@ -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 })
@@ -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: {
@@ -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, [{
@@ -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])
}
})