@ng-doc/builder
Version:
<!-- PROJECT LOGO --> <br /> <div align="center"> <a href="https://github.com/ng-doc/ng-doc"> <img src="https://ng-doc.com/assets/images/ng-doc.svg?raw=true" alt="Logo" height="150px"> </a>
27 lines • 1.27 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.invalidateCacheIfNeeded = invalidateCacheIfNeeded;
const tslib_1 = require("tslib");
const fs = tslib_1.__importStar(require("fs"));
const create_cache_1 = require("./create-cache");
const get_cache_dir_path_1 = require("./get-cache-dir-path");
const is_cache_valid_1 = require("./is-cache-valid");
const update_cache_1 = require("./update-cache");
const CORE_CACHE_ID = 'ng-doc-core';
/**
* Checks the version of the current package and invalidates the cache if necessary
* @param coreFiles - list of core files, if they were changed, the cache will be invalidated
*/
function invalidateCacheIfNeeded(coreFiles = []) {
const cacheDirPath = (0, get_cache_dir_path_1.getCacheDirPath)();
const version = require('../../../package.json').version;
const cache = (0, create_cache_1.createCache)(version, coreFiles);
const isValid = (0, is_cache_valid_1.isCacheValid)(CORE_CACHE_ID, cache);
if (!isValid) {
fs.rmSync(cacheDirPath, { recursive: true, force: true });
}
fs.mkdirSync(cacheDirPath, { recursive: true });
(0, update_cache_1.updateCache)(CORE_CACHE_ID, cache);
return isValid;
}
//# sourceMappingURL=invalidate-cache-if-needed.js.map
;