mirror of https://github.com/status-im/metro.git
Make cache method public
Reviewed By: jeanlauliac Differential Revision: D5804391 fbshipit-source-id: 8da732a440111ca5d89d51fa9e4c2727d386bbff
This commit is contained in:
parent
5fa193bdee
commit
090df5c104
|
@ -153,6 +153,14 @@ class FileBasedCache {
|
|||
return result;
|
||||
}
|
||||
|
||||
resetCache(reporter: Reporter) {
|
||||
rimraf.sync(path.join(this._rootPath, 'last_collected'));
|
||||
rimraf.sync(path.join(this._rootPath, 'cache'));
|
||||
reporter.update({type: 'transform_cache_reset'});
|
||||
this._cacheWasReset = true;
|
||||
this._lastCollected = Date.now();
|
||||
}
|
||||
|
||||
/**
|
||||
* We verify the source hash matches to ensure we always favor rebuilding when
|
||||
* source change (rather than just using fs.mtime(), a bit less robust).
|
||||
|
@ -217,7 +225,7 @@ class FileBasedCache {
|
|||
*/
|
||||
_collectIfNecessarySync(options: CacheOptions) {
|
||||
if (options.resetCache && !this._cacheWasReset) {
|
||||
this._resetCache(options.reporter);
|
||||
this.resetCache(options.reporter);
|
||||
return;
|
||||
}
|
||||
const lastCollected = this._lastCollected;
|
||||
|
@ -229,14 +237,6 @@ class FileBasedCache {
|
|||
}
|
||||
}
|
||||
|
||||
_resetCache(reporter: Reporter) {
|
||||
rimraf.sync(path.join(this._rootPath, 'last_collected'));
|
||||
rimraf.sync(path.join(this._rootPath, 'cache'));
|
||||
reporter.update({type: 'transform_cache_reset'});
|
||||
this._cacheWasReset = true;
|
||||
this._lastCollected = Date.now();
|
||||
}
|
||||
|
||||
/**
|
||||
* We want to avoid preventing tool use if the cleanup fails for some reason,
|
||||
* but still provide some chance for people to report/fix things.
|
||||
|
|
Loading…
Reference in New Issue