mirror of https://github.com/status-im/metro.git
Updates from Wed Mar 4
- [ReactNative] modernize DatePicker | Spencer Ahrens - React Native: Force !ExecutionEnvironment.canUseDOM | Tim Yung - [react-packager] Recover and warn from corrupted cache file | Amjad Masad - [ReactNative] Github repo's gitignore is written at export | Amjad Masad - [ReactNative] Use strings instead of constants for keyboardDismissMode | Christopher Chedeau
This commit is contained in:
parent
f76e0b593d
commit
164c3ea712
|
@ -112,13 +112,23 @@ Cache.prototype._persistCache = function() {
|
|||
return this._persisting;
|
||||
};
|
||||
|
||||
function loadCacheSync(cacheFilepath) {
|
||||
function loadCacheSync(cachePath) {
|
||||
var ret = Object.create(null);
|
||||
if (!fs.existsSync(cacheFilepath)) {
|
||||
if (!fs.existsSync(cachePath)) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
var cacheOnDisk = JSON.parse(fs.readFileSync(cacheFilepath));
|
||||
var cacheOnDisk;
|
||||
try {
|
||||
cacheOnDisk = JSON.parse(fs.readFileSync(cachePath));
|
||||
} catch (e) {
|
||||
if (e instanceof SyntaxError) {
|
||||
console.warn('Unable to parse cache file. Will clear and continue.');
|
||||
fs.unlinkSync(cachePath);
|
||||
return ret;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
// Filter outdated cache and convert to promises.
|
||||
Object.keys(cacheOnDisk).forEach(function(key) {
|
||||
|
|
Loading…
Reference in New Issue