-
Notifications
You must be signed in to change notification settings - Fork 46
feat: Add support for 'npm-shrinkwrap.json' #747
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,6 +111,33 @@ func TestExtractor_FileRequired(t *testing.T) { | |
wantRequired: true, | ||
wantResultMetric: stats.FileRequiredResultOK, | ||
}, | ||
{ | ||
name: "npm-shrinkwrap.json", | ||
path: filepath.FromSlash("npm-shrinkwrap.json"), | ||
wantRequired: true, | ||
wantResultMetric: stats.FileRequiredResultOK, | ||
}, | ||
{ | ||
name: "npm-shrinkwrap.json at the end of a path", | ||
path: filepath.FromSlash("path/to/my/npm-shrinkwrap.json"), | ||
wantRequired: true, | ||
wantResultMetric: stats.FileRequiredResultOK, | ||
}, | ||
{ | ||
name: "npm-shrinkwrap.json as path segment", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also add tests for extraction working properly with some example npm.shrinkwrap.json files? See packagelockjson-v1_test.go. You can create a similar file called shrinkwrap_test.go There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder how useful this is considering that the files are identical and only the name changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be helpful if we can support this behavior but for the moment, I don't see a clean way to do so.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that the precedence behavior was added let's add a test for it too |
||
path: filepath.FromSlash("path/to/my/npm-shrinkwrap.json/file"), | ||
wantRequired: false, | ||
}, | ||
{ | ||
name: "npm-shrinkwrap.json.file (wrong extension)", | ||
path: filepath.FromSlash("path/to/my/npm-shrinkwrap.json.file"), | ||
wantRequired: false, | ||
}, | ||
{ | ||
name: "path.to.my.npm-shrinkwrap.json", | ||
path: filepath.FromSlash("path.to.my.npm-shrinkwrap.json"), | ||
wantRequired: false, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use path.Dir instead of strings.TrimSuffix - https://pkg.go.dev/path#Dir