From 090df5c104deba61bd5c365ea47c5a2489faccf0 Mon Sep 17 00:00:00 2001 From: Miguel Jimenez Esun Date: Tue, 12 Sep 2017 07:55:31 -0700 Subject: [PATCH] Make cache method public Reviewed By: jeanlauliac Differential Revision: D5804391 fbshipit-source-id: 8da732a440111ca5d89d51fa9e4c2727d386bbff --- .../metro-bundler/src/lib/TransformCaching.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/metro-bundler/src/lib/TransformCaching.js b/packages/metro-bundler/src/lib/TransformCaching.js index 5018daa2..0e961ab2 100644 --- a/packages/metro-bundler/src/lib/TransformCaching.js +++ b/packages/metro-bundler/src/lib/TransformCaching.js @@ -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.