Innovenergy_trunk/frontend/node_modules/testcafe/lib/compiler/test-file/cache-proxy.js

46 lines
5.1 KiB
JavaScript

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const api_based_1 = __importDefault(require("./api-based"));
const Module = require('module');
let cachePrefix = null;
let storedComplilerId = null;
let cachePrevented = false;
function getFileNameCacheKey(fileName) {
if (!cachePrevented && cachePrefix && storedComplilerId !== cachePrefix &&
!api_based_1.default._isNodeModulesDep(fileName) &&
!api_based_1.default._isTestCafeLibDep(fileName))
return `${fileName}_${cachePrefix}`;
return fileName;
}
const handlers = {
get: function (target, filename) {
return target[getFileNameCacheKey(filename)];
},
set: function (target, filename, value) {
target[getFileNameCacheKey(filename)] = value;
return true;
},
};
class RequireCacheProxy {
constructor() {
this._proxy = new Proxy(Module._cache, handlers);
Module._cache = this._proxy;
}
startExternalCaching(compilerId) {
if (!storedComplilerId)
storedComplilerId = compilerId;
cachePrefix = compilerId;
}
stopExternalCaching() {
cachePrefix = null;
}
preventCaching() {
cachePrevented = true;
}
}
exports.default = new RequireCacheProxy();
module.exports = exports.default;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2FjaGUtcHJveHkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY29tcGlsZXIvdGVzdC1maWxlL2NhY2hlLXByb3h5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsNERBQXVEO0FBR3ZELE1BQU0sTUFBTSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQztBQUVqQyxJQUFJLFdBQVcsR0FBa0IsSUFBSSxDQUFDO0FBQ3RDLElBQUksaUJBQWlCLEdBQWtCLElBQUksQ0FBQztBQUM1QyxJQUFJLGNBQWMsR0FBRyxLQUFLLENBQUM7QUFFM0IsU0F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