| 681 | * @returns {void} |
| 682 | */ |
| 683 | const storeResult = (lockfile, url, result, callback) => { |
| 684 | if (result.storeLock) { |
| 685 | storeLockEntry(lockfile, url, result.entry); |
| 686 | if (!cacheLocation || !result.content) { |
| 687 | return callback(null, result); |
| 688 | } |
| 689 | const key = getCacheKey(result.entry.resolved); |
| 690 | const filePath = join(intermediateFs, cacheLocation, key); |
| 691 | mkdirp(intermediateFs, dirname(intermediateFs, filePath), (err) => { |
| 692 | if (err) return callback(err); |
| 693 | intermediateFs.writeFile(filePath, result.content, (err) => { |
| 694 | if (err) return callback(err); |
| 695 | callback(null, result); |
| 696 | }); |
| 697 | }); |
| 698 | } else { |
| 699 | storeLockEntry(lockfile, url, "no-cache"); |
| 700 | callback(null, result); |
| 701 | } |
| 702 | }; |
| 703 | |
| 704 | for (const { scheme, fetch } of schemes) { |
| 705 | /** |