File tree Expand file tree Collapse file tree 3 files changed +24
-3
lines changed
Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff 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} )
Original file line number Diff line number Diff line change 66export 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 - z A - Z 0 - 9 _ - ] + (?: \/ [ a - z A - Z 0 - 9 _ - ] + ) ? ) @ | ( [ a - z A - Z 0 - 9 _ - ] + ) @ ) / gm
13+
1114 let match
1215 while ( ( match = packageNameRegex . exec ( content ) ) !== null ) {
1316 const packageName = ( match [ 1 ] || match [ 2 ] ) . trim ( )
You can’t perform that action at this time.
0 commit comments