Skip to content

Commit 402a7d4

Browse files
committed
Ensure parent directory exists before writing cache hash file
1 parent 7dac383 commit 402a7d4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

gc.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ const core = require('@actions/core')
55

66
function init(cacheConfig) {
77
core.startGroup(`Computing initial ${cacheConfig.name} cache hash`)
8-
fs.writeFileSync(cacheConfig.paths[0] + '.sha256', computeCacheHash(cacheConfig.paths[0]))
8+
const hashFile = cacheConfig.paths[0] + '.sha256'
9+
const parentDir = path.dirname(hashFile)
10+
if (!fs.existsSync(parentDir)) {
11+
fs.mkdirSync(parentDir, { recursive: true })
12+
}
13+
fs.writeFileSync(hashFile, computeCacheHash(cacheConfig.paths[0]))
914
core.endGroup()
1015
}
1116

0 commit comments

Comments
 (0)