Skip to content

Commit

Permalink
Only use cache layer if yarn.lock AND package.json match
Browse files Browse the repository at this point in the history
  • Loading branch information
c0d1ngm0nk3y authored and mhdawson committed Nov 13, 2024
1 parent 0dca4c6 commit 167542f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion install_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (ip YarnInstallProcess) ShouldRun(workingDir string, metadata map[string]in
return true, "", fmt.Errorf("failed to write temp file for %s: %w", file.Name(), err)
}

sum, err := ip.summer.Sum(filepath.Join(workingDir, "yarn.lock"), file.Name())
sum, err := ip.summer.Sum(filepath.Join(workingDir, "yarn.lock"), filepath.Join(workingDir, "package.json"), file.Name())
if err != nil {
return true, "", fmt.Errorf("unable to sum config files: %w", err)
}
Expand Down
3 changes: 2 additions & 1 deletion install_process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ func testInstallProcess(t *testing.T, context spec.G, it spec.S) {
"cache_sha": "some-sha",
})
Expect(summer.SumCall.Receives.Paths[0]).To(Equal(filepath.Join(workingDir, "yarn.lock")))
Expect(summer.SumCall.Receives.Paths[1]).To(ContainSubstring("config-file"))
Expect(summer.SumCall.Receives.Paths[1]).To(Equal(filepath.Join(workingDir, "package.json")))
Expect(summer.SumCall.Receives.Paths[2]).To(ContainSubstring("config-file"))
Expect(run).To(BeTrue())
Expect(sha).To(Equal("some-other-sha"))
Expect(err).NotTo(HaveOccurred())
Expand Down

0 comments on commit 167542f

Please sign in to comment.