Skip to content

Commit 60502da

Browse files
authored
feat(yarn): add support dependency location for yarn.lock (#141)
1 parent d7c965d commit 60502da

File tree

2 files changed

+2811
-2783
lines changed

2 files changed

+2811
-2783
lines changed

pkg/nodejs/yarn/parse.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ func (p *Parser) Parse(r dio.ReadSeekerAt) (libs []types.Library, deps []types.D
7171
unique := map[string]struct{}{}
7272
var lib types.Library
7373
var skipPackage bool
74+
var lineNumber int // It is used to save dependency location
7475
for scanner.Scan() {
76+
lineNumber++
7577
line := scanner.Text()
7678
if len(line) < 1 {
7779
continue
@@ -114,6 +116,12 @@ func (p *Parser) Parse(r dio.ReadSeekerAt) (libs []types.Library, deps []types.D
114116
continue
115117
}
116118
lib.Name = name
119+
lib.Locations = append(lib.Locations, types.Location{
120+
// we only parse name and version fields for dependency
121+
// use line number of dependency name for location
122+
StartLine: lineNumber,
123+
EndLine: lineNumber,
124+
})
117125
}
118126
}
119127
return libs, nil, nil

0 commit comments

Comments
 (0)