File tree 1 file changed +9
-1
lines changed
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ var releasesData []byte
26
26
const (
27
27
downloadURL = "https://nodejs.org/dist/%s/"
28
28
packageJSON = "package.json"
29
+ nodeModules = "node_modules"
29
30
)
30
31
31
32
type Runtime struct {
@@ -64,8 +65,15 @@ func (r *Runtime) supports(testCmd string, cmd []string) bool {
64
65
65
66
func (r * Runtime ) GetHash (tool types.Tool ) (string , error ) {
66
67
if ! tool .Source .IsGit () && tool .WorkingDir != "" {
68
+ var prefix string
69
+ // This hashes if the node_modules directory was deleted
70
+ if s , err := os .Stat (filepath .Join (tool .WorkingDir , nodeModules )); err == nil {
71
+ prefix = hash .Digest (tool .WorkingDir + s .ModTime ().String ())[:7 ]
72
+ } else if s , err := os .Stat (tool .WorkingDir ); err == nil {
73
+ prefix = hash .Digest (tool .WorkingDir + s .ModTime ().String ())[:7 ]
74
+ }
67
75
if s , err := os .Stat (filepath .Join (tool .WorkingDir , packageJSON )); err == nil {
68
- return hash .Digest (tool .WorkingDir + s .ModTime ().String ())[:7 ], nil
76
+ return prefix + hash .Digest (tool .WorkingDir + s .ModTime ().String ())[:7 ], nil
69
77
}
70
78
}
71
79
return "" , nil
You can’t perform that action at this time.
0 commit comments