Skip to content

Commit

Permalink
feat(nodejs): add the workspaces field to the package (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikpivkin authored Jun 19, 2023
1 parent a0de978 commit 809cdd1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/nodejs/packagejson/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package packagejson

import (
"encoding/json"
"github.com/aquasecurity/go-dep-parser/pkg/utils"
"io"

"github.com/aquasecurity/go-dep-parser/pkg/types"
"github.com/aquasecurity/go-dep-parser/pkg/utils"
"golang.org/x/xerrors"
)

Expand All @@ -15,12 +15,14 @@ type packageJSON struct {
License interface{} `json:"license"`
Dependencies map[string]string `json:"dependencies"`
OptionalDependencies map[string]string `json:"optionalDependencies"`
Workspaces []string `json:"workspaces"`
}

type Package struct {
types.Library
Dependencies map[string]string
OptionalDependencies map[string]string
Workspaces []string
}

type Parser struct{}
Expand Down Expand Up @@ -50,6 +52,7 @@ func (p *Parser) Parse(r io.Reader) (Package, error) {
},
Dependencies: pkgJSON.Dependencies,
OptionalDependencies: pkgJSON.OptionalDependencies,
Workspaces: pkgJSON.Workspaces,
}, nil
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/nodejs/packagejson/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ func TestParse(t *testing.T) {
OptionalDependencies: map[string]string{
"colors": "^1.4.0",
},
Workspaces: []string{
"packages/*",
"backend",
},
},
},
{
Expand Down
4 changes: 4 additions & 0 deletions pkg/nodejs/packagejson/testdata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"framework",
"web"
],
"workspaces": [
"packages/*",
"backend"
],
"homepage": "https://getbootstrap.com/",
"author": "The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)",
"contributors": [
Expand Down

0 comments on commit 809cdd1

Please sign in to comment.