@ostro/filesystem 0.0.0-alpha.2 → 0.0.0-alpha.6
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/.github/workflows/npm-publish.yml +22 -0
- package/LICENSE.md +21 -21
- package/README.md +36 -36
- package/adapter/CoreAdapter.js +84 -84
- package/adapter/azure.js +67 -67
- package/adapter/local.js +140 -140
- package/adapter/s3.js +83 -83
- package/callbackHandler.js +48 -48
- package/clients/azure.js +26 -26
- package/clients/s3.js +16 -16
- package/directoryCreateException.js +13 -13
- package/fileDeleteException.js +12 -12
- package/fileNotFoundException.js +13 -13
- package/fileUploadException.js +12 -12
- package/filesystem.js +276 -278
- package/filesystemAdapter.js +97 -97
- package/filesystemManager.js +87 -134
- package/filesystemServiceProvider.js +48 -47
- package/invalidArgumentException.js +11 -11
- package/package.json +5 -2
package/fileDeleteException.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const fileNotFoundExceptionContract = require('@ostro/contracts/filesystem/fileNotFoundException')
|
|
2
|
-
class FileNotFoundException extends fileNotFoundExceptionContract {
|
|
3
|
-
constructor(errors, path) {
|
|
4
|
-
super();
|
|
5
|
-
this.name = this.constructor.name;
|
|
6
|
-
this.message = 'Unable to delete ';
|
|
7
|
-
this.errors = errors;
|
|
8
|
-
this.statusCode = 500;
|
|
9
|
-
Error.captureStackTrace(this, this.constructor);
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
}
|
|
1
|
+
const fileNotFoundExceptionContract = require('@ostro/contracts/filesystem/fileNotFoundException')
|
|
2
|
+
class FileNotFoundException extends fileNotFoundExceptionContract {
|
|
3
|
+
constructor(errors, path) {
|
|
4
|
+
super();
|
|
5
|
+
this.name = this.constructor.name;
|
|
6
|
+
this.message = 'Unable to delete ';
|
|
7
|
+
this.errors = errors;
|
|
8
|
+
this.statusCode = 500;
|
|
9
|
+
Error.captureStackTrace(this, this.constructor);
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
13
|
module.exports = FileNotFoundException
|
package/fileNotFoundException.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const fileNotFoundExceptionContract = require('@ostro/contracts/filesystem/fileNotFoundException')
|
|
2
|
-
class FileNotFoundException extends fileNotFoundExceptionContract {
|
|
3
|
-
constructor(errors) {
|
|
4
|
-
super();
|
|
5
|
-
|
|
6
|
-
this.name = this.constructor.name;
|
|
7
|
-
this.message = 'Specefied file is not found';
|
|
8
|
-
this.errors = errors;
|
|
9
|
-
this.statusCode = 404;
|
|
10
|
-
Error.captureStackTrace(this, this.constructor);
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
}
|
|
1
|
+
const fileNotFoundExceptionContract = require('@ostro/contracts/filesystem/fileNotFoundException')
|
|
2
|
+
class FileNotFoundException extends fileNotFoundExceptionContract {
|
|
3
|
+
constructor(errors) {
|
|
4
|
+
super();
|
|
5
|
+
|
|
6
|
+
this.name = this.constructor.name;
|
|
7
|
+
this.message = 'Specefied file is not found';
|
|
8
|
+
this.errors = errors;
|
|
9
|
+
this.statusCode = 404;
|
|
10
|
+
Error.captureStackTrace(this, this.constructor);
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
14
|
module.exports = FileNotFoundException
|
package/fileUploadException.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const FileUploadExceptionContract = require('@ostro/contracts/filesystem/fileUploadException')
|
|
2
|
-
class FileUploadException extends FileUploadExceptionContract {
|
|
3
|
-
constructor(errors) {
|
|
4
|
-
super();
|
|
5
|
-
this.name = this.constructor.name;
|
|
6
|
-
this.message = 'Error in upload file';
|
|
7
|
-
this.errors = errors
|
|
8
|
-
this.statusCode = 500;
|
|
9
|
-
Error.captureStackTrace(this, this.constructor);
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
}
|
|
1
|
+
const FileUploadExceptionContract = require('@ostro/contracts/filesystem/fileUploadException')
|
|
2
|
+
class FileUploadException extends FileUploadExceptionContract {
|
|
3
|
+
constructor(errors) {
|
|
4
|
+
super();
|
|
5
|
+
this.name = this.constructor.name;
|
|
6
|
+
this.message = 'Error in upload file';
|
|
7
|
+
this.errors = errors
|
|
8
|
+
this.statusCode = 500;
|
|
9
|
+
Error.captureStackTrace(this, this.constructor);
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
13
|
module.exports = FileUploadException
|
package/filesystem.js
CHANGED
|
@@ -1,279 +1,277 @@
|
|
|
1
|
-
const FilesystemContract = require('@ostro/contracts/filesystem/filesystem')
|
|
2
|
-
const fs = require('fs-extra')
|
|
3
|
-
const Finder = require('filehound')
|
|
4
|
-
const path = require('path')
|
|
5
|
-
const FileNotFoundException = require('./fileNotFoundException')
|
|
6
|
-
const FileDeleteException = require('./fileDeleteException')
|
|
7
|
-
const FileUploadException = require('./fileUploadException')
|
|
8
|
-
const DirectoryCreateException = require('./directoryCreateException')
|
|
9
|
-
class Filesystem extends FilesystemContract {
|
|
10
|
-
|
|
11
|
-
exists($path) {
|
|
12
|
-
return fs.access($path).then(res => true).catch(err => Promise.resolve(false));
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
missing($path) {
|
|
16
|
-
return !this.exists($path);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
get($path) {
|
|
20
|
-
return fs.readFile($path, 'utf8').catch(err => {
|
|
21
|
-
throw new FileNotFoundException(`File does not exist at path ${$path}.`);
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
put($path, $contents) {
|
|
27
|
-
return fs.writeFile($path, $contents);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
replaceInFile($search, $replace, $path) {
|
|
31
|
-
this.get($path).then(content => this.put($path, content.replace($search, $replace)));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
prepend($path, $data) {
|
|
35
|
-
return this.exists($path).then(res => this.put($path, ($data + this.get($path)))).catch(err => this.put($path, $data))
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
append($path, $data) {
|
|
39
|
-
return fs.appendFile($path, $data);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
chmod($path, $mode = null) {
|
|
43
|
-
if ($mode) {
|
|
44
|
-
return fs.chmod($path, $mode);
|
|
45
|
-
}
|
|
46
|
-
return fs.stat($path).then(stat => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
$
|
|
56
|
-
|
|
57
|
-
let $
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
$
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
let $
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
$
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
$path
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
let $
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
$item
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
await this.
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
278
|
-
}
|
|
1
|
+
const FilesystemContract = require('@ostro/contracts/filesystem/filesystem')
|
|
2
|
+
const fs = require('fs-extra')
|
|
3
|
+
const Finder = require('filehound')
|
|
4
|
+
const path = require('path')
|
|
5
|
+
const FileNotFoundException = require('./fileNotFoundException')
|
|
6
|
+
const FileDeleteException = require('./fileDeleteException')
|
|
7
|
+
const FileUploadException = require('./fileUploadException')
|
|
8
|
+
const DirectoryCreateException = require('./directoryCreateException')
|
|
9
|
+
class Filesystem extends FilesystemContract {
|
|
10
|
+
|
|
11
|
+
exists($path) {
|
|
12
|
+
return fs.access($path).then(res => true).catch(err => Promise.resolve(false));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
missing($path) {
|
|
16
|
+
return !this.exists($path);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get($path) {
|
|
20
|
+
return fs.readFile($path, 'utf8').catch(err => {
|
|
21
|
+
throw new FileNotFoundException(`File does not exist at path ${$path}.`);
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
put($path, $contents) {
|
|
27
|
+
return fs.writeFile($path, $contents);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
replaceInFile($search, $replace, $path) {
|
|
31
|
+
this.get($path).then(content => this.put($path, content.replace($search, $replace)));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
prepend($path, $data) {
|
|
35
|
+
return this.exists($path).then(res => this.put($path, ($data + this.get($path)))).catch(err => this.put($path, $data))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
append($path, $data) {
|
|
39
|
+
return fs.appendFile($path, $data);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
chmod($path, $mode = null) {
|
|
43
|
+
if ($mode) {
|
|
44
|
+
return fs.chmod($path, $mode);
|
|
45
|
+
}
|
|
46
|
+
return fs.stat($path).then(stat => {
|
|
47
|
+
return stats.mode
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async delete($paths) {
|
|
53
|
+
$paths = Array.isArray($paths) ? $paths : arguments;
|
|
54
|
+
|
|
55
|
+
let $success = true;
|
|
56
|
+
|
|
57
|
+
for (let $path of $paths) {
|
|
58
|
+
try {
|
|
59
|
+
if (!await fs.remove($path)) {
|
|
60
|
+
$success = false;
|
|
61
|
+
}
|
|
62
|
+
} catch ($e) {
|
|
63
|
+
$success = false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return $success;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
move($path, $target) {
|
|
71
|
+
return fs.move($path, $target);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
copy($path, $target) {
|
|
75
|
+
return fs.copy($path, $target);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
link($target, $link, $force = false) {
|
|
79
|
+
return fs.symlink($target, $link, 'junction')
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
relativeLink($target, $link, $force) {
|
|
83
|
+
$target = path.relative($target, $link);
|
|
84
|
+
return this.link($target, $link, $force);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
name($path) {
|
|
88
|
+
return pathinfo($path, PATHINFO_FILENAME);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
basename($path) {
|
|
92
|
+
return pathinfo($path, PATHINFO_BASENAME);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
dirname($path) {
|
|
96
|
+
return pathinfo($path, PATHINFO_DIRNAME);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
extension($path) {
|
|
100
|
+
return pathinfo($path, PATHINFO_EXTENSION);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
guessExtension($path) {
|
|
104
|
+
return path.extname($path)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
type($path) {
|
|
108
|
+
return filetype($path);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
mimeType($path) {
|
|
112
|
+
return finfo_file(finfo_open(FILEINFO_MIME_TYPE), $path);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
size($path) {
|
|
116
|
+
return filesize($path);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
lastModified($path) {
|
|
120
|
+
return filemtime($path);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
isDirectory($directory) {
|
|
124
|
+
return is_dir($directory);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
isReadable($path) {
|
|
128
|
+
return is_readable($path);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
isWritable($path) {
|
|
132
|
+
return is_writable($path);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
isFile($file) {
|
|
136
|
+
return fs.lstat($file).then(stats => stats.isFile()).catch(err => false);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
glob($pattern) {
|
|
140
|
+
return Finder.create().glob($pattern).find();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
requireOnce($path, $data = []) {
|
|
144
|
+
return this.isFile($path).then($exists => {
|
|
145
|
+
|
|
146
|
+
if ($exists) {
|
|
147
|
+
return require($path);
|
|
148
|
+
|
|
149
|
+
} else {
|
|
150
|
+
throw new FileNotFoundException("File does not exist at path {$path}.");
|
|
151
|
+
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
files($directory, $hidden = false) {
|
|
159
|
+
let inst = Finder.create().path($directory)
|
|
160
|
+
if ($hidden) {
|
|
161
|
+
inst.ignoreHiddenDirectories()
|
|
162
|
+
}
|
|
163
|
+
return inst.depth(0).find()
|
|
164
|
+
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
allFiles($directory, $hidden = false) {
|
|
168
|
+
let inst = Finder.create().path($directory)
|
|
169
|
+
if ($hidden) {
|
|
170
|
+
inst.ignoreHiddenDirectories()
|
|
171
|
+
}
|
|
172
|
+
return inst.find()
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
directories($directory) {
|
|
177
|
+
|
|
178
|
+
return Finder.create().path($directory).directory().depth(0).sortByName()
|
|
179
|
+
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
ensureDirectoryExists($path, $mode = 0o755, $recursive = true) {
|
|
183
|
+
return fs.ensureDir($path, $mode).then($exists => true).catch(err => false)
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
makeDirectory($path, $mode = 0o755, $recursive = false, $force = false) {
|
|
188
|
+
return fs.mkdir($path, {
|
|
189
|
+
mode: $mode,
|
|
190
|
+
recursive: $recursive
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
async moveDirectory($from, $to, $overwrite = false) {
|
|
196
|
+
if ($overwrite && await this.isDirectory($to) && !await this.deleteDirectory($to)) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return await fs.rename($from, $to) === true;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
async copyDirectory($directory, $destination, $options = null) {
|
|
204
|
+
if (!this.isDirectory($directory)) {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
$options = $options ? $options : FilesystemIterator.SKIP_DOTS;
|
|
209
|
+
|
|
210
|
+
this.ensureDirectoryExists($destination);
|
|
211
|
+
|
|
212
|
+
let $items = await fs.readdir($directory, $options)
|
|
213
|
+
|
|
214
|
+
for (let $item of $items) {
|
|
215
|
+
$item = await fs.stat();
|
|
216
|
+
|
|
217
|
+
$target = path.join($destination, $item.getBasename())
|
|
218
|
+
|
|
219
|
+
if ($item.isDirectory()) {
|
|
220
|
+
$path = $item.getPathname();
|
|
221
|
+
|
|
222
|
+
if (!await this.copyDirectory($path, $target, $options)) {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
} else {
|
|
226
|
+
if (!await this.copy($item.getPathname(), $target)) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
async deleteDirectory($directory, $preserve = false) {
|
|
236
|
+
if (!await this.isDirectory($directory)) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
let $items = await fs.readdir($directory)
|
|
241
|
+
|
|
242
|
+
for (let $item of $items) {
|
|
243
|
+
$item = await fs.stat();
|
|
244
|
+
|
|
245
|
+
if ($item.isDirectory() && !$item.isSymbolicLink()) {
|
|
246
|
+
await this.deleteDirectory($item.getPathname());
|
|
247
|
+
} else {
|
|
248
|
+
await this.delete($item.getPathname());
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (!$preserve) {
|
|
253
|
+
await this.delete($directory, true);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
async deleteDirectories($directory) {
|
|
260
|
+
$allDirectories = await this.directories($directory);
|
|
261
|
+
|
|
262
|
+
if (!empty($allDirectories)) {
|
|
263
|
+
for (let $directoryName of $allDirectories) {
|
|
264
|
+
await this.deleteDirectory($directoryName);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
cleanDirectory($directory) {
|
|
274
|
+
return this.deleteDirectory($directory, true);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
279
277
|
module.exports = Filesystem
|