Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/**
* Stored options for this instance
* @type {Object}
*/
this.options = assign(Object.create(defaultOptions), options || {});
var cacheFile = getCacheFile(this.options.cacheLocation || this.options.cacheFile);
/**
* cache used to not operate on files that haven't changed since last successful
* execution (e.g. file passed with no errors and no warnings
* @type {Object}
*/
this._fileCache = fileEntryCache.create(cacheFile); // eslint-disable-line no-underscore-dangle
if (!this.options.cache) {
this._fileCache.destroy(); // eslint-disable-line no-underscore-dangle
}
// load in additional rules
if (this.options.rulePaths) {
this.options.rulePaths.forEach(function(rulesdir) {
debug("Loading rules from " + rulesdir);
rules.load(rulesdir);
});
}
Object.keys(this.options.rules || {}).forEach(function(name) {
validator.validateRuleOptions(name, this.options.rules[name], "CLI");
}.bind(this));
options = lodash.assign(Object.create(null), defaultOptions, options);
/**
* Stored options for this instance
* @type {Object}
*/
this.options = options;
var cacheFile = getCacheFile(this.options.cacheLocation || this.options.cacheFile, this.options.cwd);
/**
* cache used to not operate on files that haven't changed since last successful
* execution (e.g. file passed with no errors and no warnings
* @type {Object}
*/
this._fileCache = fileEntryCache.create(cacheFile);
if (!this.options.cache) {
this._fileCache.destroy();
}
// load in additional rules
if (this.options.rulePaths) {
var cwd = this.options.cwd;
this.options.rulePaths.forEach(function(rulesdir) {
debug("Loading rules from " + rulesdir);
rules.load(rulesdir, cwd);
});
}
Object.keys(this.options.rules || {}).forEach(function(name) {
validator.validateRuleOptions(name, this.options.rules[name], "CLI");
/**
* Stored options for this instance
* @type {Object}
*/
this.options = assign(Object.create(defaultOptions), options || {});
var cacheFile = getCacheFile(this.options.cacheLocation || this.options.cacheFile);
/**
* cache used to not operate on files that haven't changed since last successful
* execution (e.g. file passed with no errors and no warnings
* @type {Object}
*/
this._fileCache = fileEntryCache.create(cacheFile); // eslint-disable-line no-underscore-dangle
if (!this.options.cache) {
this._fileCache.destroy(); // eslint-disable-line no-underscore-dangle
}
// load in additional rules
if (this.options.rulePaths) {
this.options.rulePaths.forEach(function(rulesdir) {
debug("Loading rules from " + rulesdir);
rules.load(rulesdir);
});
}
Object.keys(this.options.rules || {}).forEach(function(name) {
validator.validateRuleOptions(name, this.options.rules[name], "CLI");
}.bind(this));
var depsCacheId = 'deps-cx-' + id;
var cacheDir = opts.cacheDir;
var flatCache = require( 'flat-cache' );
var fileEntryCache = require( 'file-entry-cache' );
if ( opts.recreate ) {
flatCache.clearCacheById( id, cacheDir );
flatCache.clearCacheById( depsCacheId, cacheDir );
}
// load the cache with id
var cache = flatCache.load( id, cacheDir );
// load the file entry cache with id, or create a new
// one if the previous one doesn't exist
var depsCacheFile = fileEntryCache.create( depsCacheId, cacheDir );
var ignoreCache = false;
// if the command was specified this can be used
// as the cache buster
if ( opts.command ) {
var configHashPersisted = cache.getKey( 'configHash' );
var hashOfConfig = hash( opts.command );
ignoreCache = configHashPersisted !== hashOfConfig;
if ( ignoreCache ) {
cache.setKey( 'configHash', hashOfConfig );
}
}
/**
* Stored options for this instance
* @type {Object}
*/
this.options = assign(Object.create(defaultOptions), options || {});
var cacheFile = getCacheFile(this.options.cacheLocation || this.options.cacheFile);
/**
* cache used to not operate on files that haven't changed since last successful
* execution (e.g. file passed with no errors and no warnings
* @type {Object}
*/
this._fileCache = fileEntryCache.create(cacheFile); // eslint-disable-line no-underscore-dangle
if (!this.options.cache) {
this._fileCache.destroy(); // eslint-disable-line no-underscore-dangle
}
// load in additional rules
if (this.options.rulePaths) {
this.options.rulePaths.forEach(function(rulesdir) {
debug("Loading rules from " + rulesdir);
rules.load(rulesdir);
});
}
Object.keys(this.options.rules || {}).forEach(function(name) {
validator.validateRuleOptions(name, this.options.rules[name], "CLI");
}.bind(this));
options = lodash.assign(Object.create(null), defaultOptions, options);
/**
* Stored options for this instance
* @type {Object}
*/
this.options = options;
var cacheFile = getCacheFile(this.options.cacheLocation || this.options.cacheFile, this.options.cwd);
/**
* cache used to not operate on files that haven't changed since last successful
* execution (e.g. file passed with no errors and no warnings
* @type {Object}
*/
this._fileCache = fileEntryCache.create(cacheFile);
if (!this.options.cache) {
this._fileCache.destroy();
}
}
constructor(cacheFileLocation) {
assert(cacheFileLocation, "Cache file location is required");
this.fileEntryCache = fileEntryCache.create(cacheFileLocation);
}
function FileCache(cacheLocation, hashOfConfig) {
const cacheFile = path.resolve(
getCacheFile(cacheLocation || DEFAULT_CACHE_LOCATION, process.cwd()),
);
debug(`Cache file is created at ${cacheFile}`);
this._fileCache = fileEntryCache.create(cacheFile);
this._hashOfConfig = hashOfConfig || DEFAULT_HASH;
}
constructor(public config: Config) {
/**
* @type {boolean}
*/
this.isEnabled = config.cache;
this.fileCache = fileEntryCache.create(config.cacheLocation);
}