-
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?
Conversation
wantResultMetric: stats.FileRequiredResultOK, | ||
}, | ||
{ | ||
name: "npm-shrinkwrap.json as path segment", |
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.
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 comment
The 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 comment
The 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.
If both package-lock.json and npm-shrinkwrap.json are present in the root of a project, npm-shrinkwrap.json will take precedence and package-lock.json will be ignored.
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.
Now that the precedence behavior was added let's add a test for it too
extractor/filesystem/language/javascript/packagelockjson/packagelockjson.go
Outdated
Show resolved
Hide resolved
// If both package-lock.json and npm-shrinkwrap.json are present in the root of a project, | ||
// npm-shrinkwrap.json will take precedence and package-lock.json will be ignored. | ||
if filepath.Base(input.Path) == "package-lock.json" { | ||
npmShrinkwrapPath := strings.TrimSuffix(input.Path, "package-lock.json") + "npm-shrinkwrap.json" |
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
wantResultMetric: stats.FileRequiredResultOK, | ||
}, | ||
{ | ||
name: "npm-shrinkwrap.json as path segment", |
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.
Now that the precedence behavior was added let's add a test for it too
What does this MR do ?
This PR adds support for
npm-shrinkwrap.json
.Related issues
#697
Other usefull links
https://docs.npmjs.com/cli/v6/configuring-npm/shrinkwrap-json