Skip to content

Commit aabba19

Browse files
committed
Fix detection of shiki@^1.29.2:
1 parent f4bab63 commit aabba19

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
"package-a@^1.0.0":
22
version "1.0.0"
33
resolved "https://registry.yarnpkg.com/package-a/-/package-a-1.0.0.tgz"
4+
integrity sha512-example123456789
45

56
"@scope/package-b@^2.0.0":
67
version "2.0.0"
78
resolved "https://registry.yarnpkg.com/@scope/package-b/-/package-b-2.0.0.tgz"
9+
integrity sha512-example123456789
810

911
"@cspell/dict-monkeyc@^1.0.10":
1012
version "1.0.10"
11-
resolved "https://registry.yarnpkg.com/@cspell/dict-monkeyc/-/dict-monkeyc-1.0.10.tgz"
13+
resolved "https://registry.yarnpkg.com/@cspell/dict-monkeyc/-/dict-monkeyc-1.0.10.tgz"
14+
integrity sha512-example123456789
15+
16+
shiki@^1.29.2:
17+
version "1.29.2"
18+
resolved "https://registry.yarnpkg.com/shiki/-/shiki-1.29.2.tgz"
19+
integrity sha512-example123456789

src/extractors/__tests__/yarn.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ describe('Yarn Extractors', () => {
1414
expect(words).toContain('package-a')
1515
expect(words).toContain('scope')
1616
expect(words).toContain('package-b')
17+
expect(words).toContain('shiki')
1718

1819
// Test for @cspell/dict-monkeyc
1920
expect(words).toContain('cspell')
@@ -23,5 +24,14 @@ describe('Yarn Extractors', () => {
2324

2425
verifyWords(words)
2526
})
27+
28+
it('should extract package names from package specifications with colons', () => {
29+
const content =
30+
'shiki@^1.29.2:\n version "1.29.2"\n resolved "https://registry.yarnpkg.com/shiki/-/shiki-1.29.2.tgz"'
31+
const words = extractFromYarnLock(content)
32+
33+
expect(words).toContain('shiki')
34+
verifyWords(words)
35+
})
2636
})
2737
})

src/extractors/yarn.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
export function extractFromYarnLock(content: string): string[] {
77
const words = new Set<string>()
88

9-
// Extract package names
10-
const packageNameRegex = /^"?([^@"]+)@|^"?(@[^/]+\/[^@"]+)@/gm
9+
// Simple regex to match package names in yarn.lock
10+
// Handles quoted ("package@") and unquoted (package@) formats
11+
const packageNameRegex =
12+
/^(?:"?([@a-zA-Z0-9_-]+(?:\/[a-zA-Z0-9_-]+)?)@|([a-zA-Z0-9_-]+)@)/gm
13+
1114
let match
1215
while ((match = packageNameRegex.exec(content)) !== null) {
1316
const packageName = (match[1] || match[2]).trim()

0 commit comments

Comments
 (0)