flat-cache 1.3.1 → 2.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  var path = require( 'path' );
2
- var fs = require( 'graceful-fs' );
3
- var del = require( 'del' ).sync;
2
+ var fs = require( 'fs' );
4
3
  var utils = require( './utils' );
4
+ var del = require( './del' );
5
5
  var writeJSON = utils.writeJSON;
6
6
 
7
7
  var cache = {
@@ -125,9 +125,7 @@ var cache = {
125
125
  * @return {Boolean} true or false if the file was successfully deleted
126
126
  */
127
127
  removeCacheFile: function () {
128
- return del( this._pathToFile, {
129
- force: true
130
- } );
128
+ return del( this._pathToFile );
131
129
  },
132
130
  /**
133
131
  * Destroy the file cache and cache content.
@@ -185,9 +183,7 @@ module.exports = {
185
183
  */
186
184
  clearCacheById: function ( docId, cacheDir ) {
187
185
  var filePath = cacheDir ? path.resolve( cacheDir, docId ) : path.resolve( __dirname, './.cache/', docId );
188
- return del( filePath, {
189
- force: true
190
- } ).length > 0;
186
+ return del( filePath );
191
187
  },
192
188
  /**
193
189
  * Remove all cache stored in the cache directory
@@ -196,8 +192,6 @@ module.exports = {
196
192
  */
197
193
  clearAll: function ( cacheDir ) {
198
194
  var filePath = cacheDir ? path.resolve( cacheDir ) : path.resolve( __dirname, './.cache/' );
199
- return del( filePath, {
200
- force: true
201
- } ).length > 0;
195
+ return del( filePath );
202
196
  }
203
197
  };
package/changelog.md CHANGED
@@ -1,5 +1,75 @@
1
1
 
2
2
  # flat-cache - Changelog
3
+ ## v2.0.1
4
+ - **Refactoring**
5
+ - upgrade node modules to latest versions - [6402ed3]( https://github.com/royriojas/flat-cache/commit/6402ed3 ), [Roy Riojas](https://github.com/Roy Riojas), 08/01/2019 21:47:05
6
+
7
+
8
+ ## v2.0.0
9
+ - **Bug Fixes**
10
+ - upgrade package.json lock file - [8d21c7b]( https://github.com/royriojas/flat-cache/commit/8d21c7b ), [Roy Riojas](https://github.com/Roy Riojas), 08/01/2019 20:03:13
11
+
12
+
13
+ - Use the same versions of node_js that eslint use - [8d23379]( https://github.com/royriojas/flat-cache/commit/8d23379 ), [Roy Riojas](https://github.com/Roy Riojas), 08/01/2019 19:25:11
14
+
15
+
16
+ - **Other changes**
17
+ - Replace circular-json with flatted ([#36](https://github.com/royriojas/flat-cache/issues/36)) - [b93aced]( https://github.com/royriojas/flat-cache/commit/b93aced ), [C. K. Tang](https://github.com/C. K. Tang), 08/01/2019 20:03:01
18
+
19
+
20
+ - Change JSON parser from circular-json to flatted & 1 more changes ([#37](https://github.com/royriojas/flat-cache/issues/37)) - [745e65a]( https://github.com/royriojas/flat-cache/commit/745e65a ), [Andy Chen](https://github.com/Andy Chen), 08/01/2019 19:17:20
21
+
22
+ * Change JSON parser from circular-json to flatted & 1 more changes
23
+
24
+ * Change JSON parser from circular-json
25
+ * Audited 2 vulnerabilities
26
+
27
+ * Update package.json
28
+
29
+ * Update Engine require
30
+
31
+ * There's a bunch of dependencies in this pkg requires node >=4, so I changed it to 4
32
+
33
+ * Remove and add node versions
34
+
35
+ * I have seen this pkg is not available with node 0.12 so I removed it
36
+ * I have added a popular used LTS version of node - 10
37
+
38
+ ## v1.3.4
39
+ - **Refactoring**
40
+ - Add del.js and utils.js to the list of files to be beautified - [9d0ca9b]( https://github.com/royriojas/flat-cache/commit/9d0ca9b ), [Roy Riojas](https://github.com/Roy Riojas), 14/11/2018 15:19:02
41
+
42
+
43
+ ## v1.3.3
44
+ - **Refactoring**
45
+ - Make sure package-lock.json is up to date - [a7d2598]( https://github.com/royriojas/flat-cache/commit/a7d2598 ), [Roy Riojas](https://github.com/Roy Riojas), 14/11/2018 14:36:08
46
+
47
+
48
+ - **Other changes**
49
+ - Removed the need for del ([#33](https://github.com/royriojas/flat-cache/issues/33)) - [c429012]( https://github.com/royriojas/flat-cache/commit/c429012 ), [S. Gilroy](https://github.com/S. Gilroy), 13/11/2018 16:56:37
50
+
51
+ * Removed the need for del
52
+
53
+ Removed the need for del as newer versions have broken backwards
54
+ compatibility. del mainly uses rimraf for deleting folders
55
+ and files, replaceing it with rimraf only is a minimal change.
56
+
57
+ * Disable glob on rimraf calls
58
+
59
+ * Added glob disable to wrong call
60
+
61
+ * Wrapped rimraf to simplify solution
62
+
63
+ ## v1.3.2
64
+ - **Refactoring**
65
+ - remove yarn.lock file - [704c6c4]( https://github.com/royriojas/flat-cache/commit/704c6c4 ), [Roy Riojas](https://github.com/Roy Riojas), 07/11/2018 18:41:08
66
+
67
+
68
+ - **undefined**
69
+ - replace circular-json with flatted ([#23](https://github.com/royriojas/flat-cache/issues/23))" - [db12d74]( https://github.com/royriojas/flat-cache/commit/db12d74 ), [Roy Riojas](https://github.com/Roy Riojas), 07/11/2018 18:40:39
70
+
71
+ This reverts commit 00f689277a75e85fef28e6a048fad227afc525e6.
72
+
3
73
  ## v1.3.1
4
74
  - **Refactoring**
5
75
  - upgrade deps to remove some security warnings - [f405719]( https://github.com/royriojas/flat-cache/commit/f405719 ), [Roy Riojas](https://github.com/Roy Riojas), 06/11/2018 15:07:31
package/del.js ADDED
@@ -0,0 +1,13 @@
1
+ var rimraf = require( 'rimraf' ).sync;
2
+ var fs = require( 'fs' );
3
+
4
+ module.exports = function del( file ) {
5
+ if ( fs.existsSync( file ) ) {
6
+ //if rimraf doesn't throw then the file has been deleted or didn't exist
7
+ rimraf( file, {
8
+ glob: false
9
+ } );
10
+ return true;
11
+ }
12
+ return false;
13
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flat-cache",
3
- "version": "1.3.1",
3
+ "version": "2.0.1",
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",
@@ -11,10 +11,11 @@
11
11
  "main": "cache.js",
12
12
  "files": [
13
13
  "cache.js",
14
- "utils.js"
14
+ "utils.js",
15
+ "del.js"
15
16
  ],
16
17
  "engines": {
17
- "node": ">=0.10.0"
18
+ "node": ">=4"
18
19
  },
19
20
  "precommit": [
20
21
  "npm run verify --silent"
@@ -23,9 +24,9 @@
23
24
  "npm run verify --silent"
24
25
  ],
25
26
  "scripts": {
26
- "beautify": "esbeautifier cache.js test/specs/**/*.js",
27
+ "beautify": "esbeautifier 'cache.js' 'utils.js' 'del.js' 'test/specs/**/*.js'",
27
28
  "beautify-check": "npm run beautify -- -k",
28
- "eslint": "eslinter cache.js utils.js specs/**/*.js",
29
+ "eslint": "eslinter 'cache.js' 'utils.js' 'del.js' 'specs/**/*.js'",
29
30
  "eslint-fix": "npm run eslint -- --fix",
30
31
  "autofix": "npm run beautify && npm run eslint-fix",
31
32
  "check": "npm run beautify-check && npm run eslint",
@@ -79,9 +80,8 @@
79
80
  "watch-run": "^1.2.2"
80
81
  },
81
82
  "dependencies": {
82
- "del": "^3.0.0",
83
83
  "flatted": "^2.0.0",
84
- "graceful-fs": "^4.1.2",
85
- "write": "^0.2.1"
84
+ "rimraf": "2.6.3",
85
+ "write": "1.0.3"
86
86
  }
87
87
  }
package/utils.js CHANGED
@@ -1,10 +1,9 @@
1
- var fs = require( 'graceful-fs' );
1
+ var fs = require( 'fs' );
2
2
  var write = require( 'write' );
3
3
  var flatted = require( 'flatted' );
4
4
 
5
5
  module.exports = {
6
-
7
- tryParse: function ( filePath, defaultValue) {
6
+ tryParse: function ( filePath, defaultValue ) {
8
7
  var result;
9
8
  try {
10
9
  result = this.readJSON( filePath );
@@ -22,18 +21,19 @@ module.exports = {
22
21
  * @returns {*} parse result
23
22
  */
24
23
  readJSON: function ( filePath ) {
25
- return flatted.parse( fs.readFileSync( filePath ).toString() );
24
+ return flatted.parse( fs.readFileSync( filePath, {
25
+ encoding: 'utf8'
26
+ } ) );
26
27
  },
27
28
 
28
29
  /**
29
- * Write json file synchronously using flatted
30
+ * Write json file synchronously using circular-json
30
31
  *
31
32
  * @method writeJSON
32
33
  * @param {String} filePath Json filepath
33
34
  * @param {*} data Object to serialize
34
35
  */
35
- writeJSON: function (filePath, data ) {
36
+ writeJSON: function ( filePath, data ) {
36
37
  write.sync( filePath, flatted.stringify( data ) );
37
38
  }
38
-
39
39
  };