Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
beyondkmp committed Sep 17, 2024
1 parent d1c680b commit 91b3528
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
9 changes: 1 addition & 8 deletions pkg/node-modules/nodeModuleCollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (t *Collector) processHoistDependencyMap() {
for _, d := range t.allDependencies {
if e, ok := t.HoiestedDependencyMap[d.alias]; ok {
if e.Version != d.Version {
t.writeToParentConflicDependency(e)
t.writeToParentConflicDependency(d)
}
}

Expand Down Expand Up @@ -288,13 +288,6 @@ func correctOptionalState(isOptional bool, childDependency *Dependency) {
// nil if already handled
func (t *Collector) resolveDependency(parentNodeModuleDir string, name string) (*Dependency, error) {
dependencyNameToDependency := t.NodeModuleDirToDependencyMap[parentNodeModuleDir]
if dependencyNameToDependency != nil {
dependency := (*dependencyNameToDependency)[name]
if dependency != nil {
return dependency, nil
}
}

dependencyDir := filepath.Join(parentNodeModuleDir, name)
info, err := os.Stat(dependencyDir)
if err == nil && !info.IsDir() {
Expand Down
6 changes: 3 additions & 3 deletions pkg/node-modules/nodeModuleCollector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestReadDependencyTreeByNpm(t *testing.T) {
g.Expect(r).To(ConsistOf([]string{
"js-tokens", "react", "remote", "loose-envify",
}))
remoteModule := collector.HoiestedDependencyMap["@electron/remote"]
remoteModule := collector.HoiestedDependencyMap["remote"]
g.Expect(remoteModule.alias).To(Equal("remote"))
g.Expect(remoteModule.Name).To(Equal("@electron/remote"))
}
Expand Down Expand Up @@ -64,7 +64,7 @@ func TestReadDependencyTreeByPnpm(t *testing.T) {
"js-tokens", "react", "remote", "loose-envify",
}))

remoteModule := collector.HoiestedDependencyMap["@electron/remote"]
remoteModule := collector.HoiestedDependencyMap["remote"]
g.Expect(remoteModule.Name).To(Equal("@electron/remote"))
g.Expect(remoteModule.alias).To(Equal("remote"))
g.Expect(remoteModule.dir).To(Equal(filepath.Join(dir, "node_modules/.pnpm/@[email protected][email protected]/node_modules/@electron/remote")))
Expand Down Expand Up @@ -101,7 +101,7 @@ func TestReadDependencyTreeForTar(t *testing.T) {
g.Expect(collector.HoiestedDependencyMap["tar"].dir).To(Equal(filepath.Join(dir, "node_modules/tar")))
g.Expect(collector.HoiestedDependencyMap["minipass"].Version).To(Equal("7.1.2"))
g.Expect(collector.HoiestedDependencyMap["minizlib"].Version).To(Equal("3.0.1"))
g.Expect(collector.HoiestedDependencyMap["tar"].conflictDependency["ansi-regex"].Version).To(Equal("5.0.1"))
g.Expect(collector.HoiestedDependencyMap["string-width-cjs"].conflictDependency["ansi-regex"].Version).To(Equal("5.0.1"))
}

func TestReadDependencyTreeForYarn(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/node-modules/tar-demo/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 91b3528

Please sign in to comment.