1
1
'use strict' ;
2
- var fs = require ( 'fs' ) ;
3
2
var path = require ( 'path' ) ;
4
3
5
4
var file = require ( './file' ) ;
@@ -12,22 +11,22 @@ cache.init = function() {
12
11
13
12
cache . get = function ( k ) {
14
13
const fullpath = file . cacheFile ( k ) ;
15
- if ( ! fs . existsSync ( fullpath ) ) return null ;
14
+ if ( ! file . exist ( fullpath ) ) return null ;
16
15
17
- return JSON . parse ( fs . readFileSync ( fullpath ) ) ;
16
+ return JSON . parse ( file . data ( fullpath ) ) ;
18
17
} ;
19
18
20
19
cache . set = function ( k , v ) {
21
20
const fullpath = file . cacheFile ( k ) ;
22
- fs . writeFileSync ( fullpath , JSON . stringify ( v ) ) ;
21
+ file . write ( fullpath , JSON . stringify ( v ) ) ;
23
22
return true ;
24
23
} ;
25
24
26
25
cache . del = function ( k ) {
27
26
const fullpath = file . cacheFile ( k ) ;
28
- if ( ! fs . existsSync ( fullpath ) ) return false ;
27
+ if ( ! file . exist ( fullpath ) ) return false ;
29
28
30
- fs . unlinkSync ( fullpath ) ;
29
+ file . rm ( fullpath ) ;
31
30
return true ;
32
31
} ;
33
32
@@ -36,7 +35,7 @@ cache.list = function() {
36
35
. filter ( x => path . extname ( x ) === '.json' )
37
36
. map ( function ( filename ) {
38
37
const k = path . basename ( filename , '.json' ) ;
39
- const stat = fs . statSync ( file . cacheFile ( k ) ) ;
38
+ const stat = file . stat ( file . cacheFile ( k ) ) ;
40
39
return {
41
40
name : k ,
42
41
size : stat . size ,
0 commit comments