flat-cache 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cache.js +3 -3
- package/changelog.md +21 -0
- package/package.json +2 -2
- package/utils.js +10 -0
package/cache.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var path = require( 'path' );
|
|
2
2
|
var fs = require( 'graceful-fs' );
|
|
3
3
|
var del = require( 'del' ).sync;
|
|
4
|
-
var
|
|
5
|
-
var writeJSON =
|
|
4
|
+
var utils = require( './utils' );
|
|
5
|
+
var writeJSON = utils.writeJSON;
|
|
6
6
|
|
|
7
7
|
var cache = {
|
|
8
8
|
/**
|
|
@@ -22,7 +22,7 @@ var cache = {
|
|
|
22
22
|
me._pathToFile = cacheDir ? path.resolve( cacheDir, docId ) : path.resolve( __dirname, './.cache/', docId );
|
|
23
23
|
|
|
24
24
|
if ( fs.existsSync( me._pathToFile ) ) {
|
|
25
|
-
me._persisted =
|
|
25
|
+
me._persisted = utils.tryParse( me._pathToFile, { } );
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
|
package/changelog.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
|
|
2
2
|
# flat-cache - Changelog
|
|
3
|
+
## v1.2.2
|
|
4
|
+
- **Bug Fixes**
|
|
5
|
+
- Do not crash if cache file is invalid JSON. ([#13](https://github.com/royriojas/flat-cache/issues/13)) - [87beaa6]( https://github.com/royriojas/flat-cache/commit/87beaa6 ), [Roy Riojas](https://github.com/Roy Riojas), 19/12/2016 21:03:35
|
|
6
|
+
|
|
7
|
+
Fixes <a target="_blank" class="info-link" href="https://github.com/royriojas/flat-cache/issues/12"><span>#12</span></a>
|
|
8
|
+
|
|
9
|
+
Not sure under which situations a cache file might exist that does
|
|
10
|
+
not contain a valid JSON structure, but just in case to cover
|
|
11
|
+
the possibility of this happening a try catch block has been added
|
|
12
|
+
|
|
13
|
+
If the cache is somehow not valid the cache will be discarded an a
|
|
14
|
+
a new cache will be stored instead
|
|
15
|
+
- **Other changes**
|
|
16
|
+
- Added travis ci support for modern node versions ([#11](https://github.com/royriojas/flat-cache/issues/11)) - [1c2b1f7]( https://github.com/royriojas/flat-cache/commit/1c2b1f7 ), [Amila Welihinda](https://github.com/Amila Welihinda), 11/11/2016 02:47:52
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
- Bumping `circular-son` version ([#10](https://github.com/royriojas/flat-cache/issues/10)) - [4d5e861]( https://github.com/royriojas/flat-cache/commit/4d5e861 ), [Andrea Giammarchi](https://github.com/Andrea Giammarchi), 02/08/2016 09:13:52
|
|
20
|
+
|
|
21
|
+
As mentioned in https://github.com/WebReflection/circular-json/issues/25 `circular-json` wan't rightly implementing the license field.
|
|
22
|
+
|
|
23
|
+
Latest version bump changed only that bit so that ESLint should now be happy.
|
|
3
24
|
## v1.2.1
|
|
4
25
|
- **Bug Fixes**
|
|
5
26
|
- Add missing utils.js file to the package. closes [#8](https://github.com/royriojas/flat-cache/issues/8) - [ec10cf2]( https://github.com/royriojas/flat-cache/commit/ec10cf2 ), [Roy Riojas](https://github.com/Roy Riojas), 01/08/2016 04:18:57
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flat-cache",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "A stupidly simple key/value storage using files to persist some data",
|
|
5
5
|
"repository": "royriojas/flat-cache",
|
|
6
6
|
"license": "MIT",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"watch-run": "^1.2.2"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"circular-json": "^0.3.
|
|
82
|
+
"circular-json": "^0.3.1",
|
|
83
83
|
"del": "^2.0.2",
|
|
84
84
|
"graceful-fs": "^4.1.2",
|
|
85
85
|
"write": "^0.2.1"
|
package/utils.js
CHANGED
|
@@ -4,6 +4,16 @@ var circularJson = require( 'circular-json' );
|
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
6
6
|
|
|
7
|
+
tryParse: function ( filePath, defaultValue) {
|
|
8
|
+
var result;
|
|
9
|
+
try {
|
|
10
|
+
result = this.readJSON( filePath );
|
|
11
|
+
} catch (ex) {
|
|
12
|
+
result = defaultValue;
|
|
13
|
+
}
|
|
14
|
+
return result;
|
|
15
|
+
},
|
|
16
|
+
|
|
7
17
|
/**
|
|
8
18
|
* Read json file synchronously using circular-json
|
|
9
19
|
*
|