imdone-core 1.53.8 → 1.53.9
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/lib/adapters/file-gateway.js +21 -15
- package/package.json +1 -1
|
@@ -4,7 +4,20 @@ let fs = require('fs')
|
|
|
4
4
|
const sanitize = require('sanitize-filename')
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
function mkdirpSync(path) {
|
|
8
|
+
console.warn('sync call')
|
|
9
|
+
return require('mkdirp').sync(path, { fs })
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function statSync(path) {
|
|
13
|
+
console.warn('sync call')
|
|
14
|
+
try {
|
|
15
|
+
return fs.statSync(path)
|
|
16
|
+
} catch {
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const gateway = {
|
|
8
21
|
init(fileSystem = fs) {
|
|
9
22
|
fs = fileSystem
|
|
10
23
|
},
|
|
@@ -53,10 +66,7 @@ module.exports = gateway = {
|
|
|
53
66
|
return fs.unlinkSync.apply({}, args)
|
|
54
67
|
},
|
|
55
68
|
|
|
56
|
-
mkdirpSync
|
|
57
|
-
console.warn('sync call')
|
|
58
|
-
return require('mkdirp').sync(path, { fs })
|
|
59
|
-
},
|
|
69
|
+
mkdirpSync,
|
|
60
70
|
|
|
61
71
|
async mkdir(path) {
|
|
62
72
|
return fs.promises.mkdir(path)
|
|
@@ -66,13 +76,7 @@ module.exports = gateway = {
|
|
|
66
76
|
return fs.promises.readFile(path, 'utf8')
|
|
67
77
|
},
|
|
68
78
|
|
|
69
|
-
statSync
|
|
70
|
-
console.warn('sync call')
|
|
71
|
-
try {
|
|
72
|
-
return fs.statSync(path)
|
|
73
|
-
} catch {
|
|
74
|
-
}
|
|
75
|
-
},
|
|
79
|
+
statSync,
|
|
76
80
|
|
|
77
81
|
readdirSyncRecursive(path) {
|
|
78
82
|
console.warn('sync call')
|
|
@@ -94,14 +98,14 @@ module.exports = gateway = {
|
|
|
94
98
|
},
|
|
95
99
|
|
|
96
100
|
preparePathForWriting(path) {
|
|
97
|
-
let stat =
|
|
101
|
+
let stat = statSync(path)
|
|
98
102
|
if (!stat) {
|
|
99
103
|
let { dir, ext } = _path.parse(path)
|
|
100
104
|
if (!ext) {
|
|
101
105
|
dir = path
|
|
102
106
|
}
|
|
103
|
-
|
|
104
|
-
stat =
|
|
107
|
+
mkdirpSync(dir)
|
|
108
|
+
stat = statSync(path)
|
|
105
109
|
}
|
|
106
110
|
return {
|
|
107
111
|
isFile: stat && stat.isFile(),
|
|
@@ -109,3 +113,5 @@ module.exports = gateway = {
|
|
|
109
113
|
}
|
|
110
114
|
}
|
|
111
115
|
}
|
|
116
|
+
|
|
117
|
+
module.exports = gateway
|