1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | const path_1 = __importDefault(require("path"));
|
7 | const build_utils_1 = require("@vercel/build-utils");
|
8 | const fs_extra_1 = __importDefault(require("fs-extra"));
|
9 | const consola_1 = __importDefault(require("consola"));
|
10 | const utils_1 = require("./utils");
|
11 | async function prepareCache({ workPath, entrypoint }) {
|
12 | const entryDir = path_1.default.dirname(entrypoint);
|
13 | utils_1.startStep('Collect cache');
|
14 | const cache = {};
|
15 | for (const dir of ['.now_cache', 'node_modules_dev', 'node_modules_prod']) {
|
16 | const activeDirectory = path_1.default.join(workPath, entryDir, dir);
|
17 | if (!fs_extra_1.default.existsSync(activeDirectory)) {
|
18 | consola_1.default.warn(activeDirectory, 'not exists. skipping!');
|
19 | continue;
|
20 | }
|
21 | const files = await build_utils_1.glob(path_1.default.join(entryDir, dir, '**'), workPath);
|
22 | consola_1.default.info(`${Object.keys(files).length} files collected from ${dir}`);
|
23 | Object.assign(cache, files);
|
24 | }
|
25 | utils_1.endStep();
|
26 | return cache;
|
27 | }
|
28 | exports.default = prepareCache;
|