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:
Christopher Chedeau 2015-03-04 08:05:38 -08:00
parent f76e0b593d
commit 164c3ea712

View File

@ -112,13 +112,23 @@ Cache.prototype._persistCache = function() {
return this._persisting; return this._persisting;
}; };
function loadCacheSync(cacheFilepath) { function loadCacheSync(cachePath) {
var ret = Object.create(null); var ret = Object.create(null);
if (!fs.existsSync(cacheFilepath)) { if (!fs.existsSync(cachePath)) {
return ret; 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. // Filter outdated cache and convert to promises.
Object.keys(cacheOnDisk).forEach(function(key) { Object.keys(cacheOnDisk).forEach(function(key) {