MCPcopy
hub / github.com/serverless/serverless / cleanupCache

Function cleanupCache

packages/serverless/lib/plugins/python/lib/clean.js:72–107  ·  view source on GitHub ↗

* Clean up static cache, remove all items in there * @return {Promise}

()

Source from the content-addressed store, hash-verified

70 * @return {Promise}
71 */
72async function cleanupCache() {
73 const cacheLocation = getUserCachePath(this.options)
74 if (fse.existsSync(cacheLocation)) {
75 let cleanupProgress
76 if (this.serverless) {
77 if (this.log) {
78 cleanupProgress = this.progress.get('python-cleanup-cache')
79 cleanupProgress.notice('Removing static caches')
80 this.log.info(`Removing static caches at: ${cacheLocation}`)
81 } else {
82 this.serverless.cli.log(`Removing static caches at: ${cacheLocation}`)
83 }
84 }
85
86 // Only remove cache folders that we added, just incase someone accidentally puts a weird
87 // static cache location so we don't remove a bunch of personal stuff
88 const files = globSync([path.join(cacheLocation, '*slspyc/')], {
89 mark: true,
90 dot: false,
91 })
92 try {
93 await Promise.all(files.map((file) => fse.remove(file)))
94 } finally {
95 cleanupProgress && cleanupProgress.remove()
96 }
97 } else {
98 if (this.serverless) {
99 if (this.log) {
100 this.log.info(`No static cache found`)
101 } else {
102 this.serverless.cli.log(`No static cache found`)
103 }
104 }
105 return
106 }
107}
108
109export { cleanup, cleanupCache }

Callers

nothing calls this directly

Calls 6

getUserCachePathFunction · 0.90
getMethod · 0.45
noticeMethod · 0.45
infoMethod · 0.45
logMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…