| 23 | const cacheManager = new CacheManager(grunt, grunt.config('cacheAge')); |
| 24 | |
| 25 | const restoreCache = async (cachePath, basePath) => { |
| 26 | if (isDisableCache || cache || !fs.existsSync(cachePath)) return; |
| 27 | await new Promise((resolve, reject) => { |
| 28 | const buffer = fs.readFileSync(cachePath); |
| 29 | unzip(buffer, (err, buffer) => { |
| 30 | if (err) { |
| 31 | console.error('An error occurred restoring rollup cache:', err); |
| 32 | process.exitCode = 1; |
| 33 | reject(err); |
| 34 | return; |
| 35 | } |
| 36 | let str = buffer.toString(); |
| 37 | // Restore cache to current basePath |
| 38 | str = str.replace(/%%basePath%%/g, basePath); |
| 39 | cache = JSON.parse(str); |
| 40 | resolve(); |
| 41 | }); |
| 42 | }); |
| 43 | }; |
| 44 | |
| 45 | const checkCache = function(invalidate) { |
| 46 | if (!cache) return; |