MCPcopy Create free account
hub / github.com/cypress-io/github-action / getNpmCache

Function getNpmCache

index.js:133–161  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

131// enforce the same npm cache folder across different operating systems
132const NPM_CACHE_FOLDER = path.join(homeDirectory, '.npm')
133const getNpmCache = () => {
134 const o = {}
135 let key = core.getInput('cache-key')
136 const hash = lockHash()
137 if (!key) {
138 if (useYarn()) {
139 key = `yarn-${platformAndArch}-${hash}`
140 } else if (usePnpm()) {
141 key = `pnpm-${platformAndArch}-${hash}`
142 } else {
143 key = `npm-${platformAndArch}-${hash}`
144 }
145 } else {
146 console.log('using custom cache key "%s"', key)
147 }
148
149 if (useYarn()) {
150 o.inputPath = path.join(homeDirectory, '.cache', 'yarn')
151 } else if (usePnpm()) {
152 o.inputPath = NPM_CACHE_FOLDER
153 } else {
154 o.inputPath = NPM_CACHE_FOLDER
155 }
156
157 // use exact restore key to prevent npm cache from growing
158 // https://glebbahmutov.com/blog/do-not-let-npm-cache-snowball/
159 o.restoreKeys = o.primaryKey = key
160 return o
161}
162
163// custom Cypress binary cache folder
164// see https://on.cypress.io/caching

Callers 2

restoreCachedNpmFunction · 0.85
saveCachedNpmFunction · 0.85

Calls 3

lockHashFunction · 0.85
useYarnFunction · 0.85
usePnpmFunction · 0.85

Tested by

no test coverage detected