Skip to content

Commit

Permalink
Work around cache module modifying input paths
Browse files Browse the repository at this point in the history
An issue in action/toolkit modifies the inputPath values passed to cache function. These changes work around this issue. 

For more details see: actions/toolkit#1378

Co-authored-by: Justin Leis <justin.leis@webewizard.com>
  • Loading branch information
Bertg and WebeWizard committed Aug 1, 2023
1 parent 9395516 commit 2bcc350
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions index.js
Expand Up @@ -31,7 +31,7 @@ const restoreCachedNpm = npmCache => {
console.log('trying to restore cached NPM modules')
return cache
.restoreCache(
npmCache.inputPaths,
npmCache.inputPaths.slice(), // Copy inputPaths, to work arround bug reported in https://github.com/actions/toolkit/pull/1378
npmCache.primaryKey,
npmCache.restoreKeys
)
Expand All @@ -50,7 +50,10 @@ const saveCachedNpm = npmCache => {
console.log('saving NPM modules')

return cache
.saveCache(npmCache.inputPaths, npmCache.primaryKey)
.saveCache(
npmCache.inputPaths.slice(), // Copy inputPaths, to work arround bug reported in https://github.com/actions/toolkit/pull/1378
npmCache.primaryKey
)
.catch(err => {
// don't throw an error if cache already exists, which may happen due to
// race conditions
Expand Down

0 comments on commit 2bcc350

Please sign in to comment.