@lvce-editor/file-system-process 2.2.0 → 2.3.0
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/dist/index.js +10 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -130,6 +130,7 @@ const Socket = 8;
|
|
|
130
130
|
const Symlink = 9;
|
|
131
131
|
const Unknown = 12;
|
|
132
132
|
|
|
133
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
133
134
|
const getDirentType = dirent => {
|
|
134
135
|
if (dirent.isFile()) {
|
|
135
136
|
return File;
|
|
@@ -177,12 +178,15 @@ const getFolderSizeInternal = async path => {
|
|
|
177
178
|
|
|
178
179
|
// @ts-ignore
|
|
179
180
|
const isEnoentErrorWindows = error => {
|
|
180
|
-
|
|
181
|
+
if (!error || !error.message) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
return error.message.includes('The system cannot find the path specified.');
|
|
181
185
|
};
|
|
182
186
|
|
|
183
187
|
// @ts-ignore
|
|
184
188
|
const isEnoentErrorLinux = error => {
|
|
185
|
-
return error.code === ENOENT;
|
|
189
|
+
return Boolean(error && error.code === ENOENT);
|
|
186
190
|
};
|
|
187
191
|
|
|
188
192
|
// @ts-ignore
|
|
@@ -262,12 +266,15 @@ const getTrashFn = isElectron => {
|
|
|
262
266
|
};
|
|
263
267
|
|
|
264
268
|
const getElectronRunAsNode = () => {
|
|
265
|
-
return process.env.ELECTRON_RUN_AS_NODE;
|
|
269
|
+
return process.env.ELECTRON_RUN_AS_NODE || '';
|
|
266
270
|
};
|
|
267
271
|
|
|
268
272
|
const isElectron = Boolean(getElectronRunAsNode()) || 'electron' in process.versions;
|
|
269
273
|
|
|
270
274
|
const trash = async path => {
|
|
275
|
+
if (!path || path.trim() === '') {
|
|
276
|
+
throw new Error('Path cannot be empty');
|
|
277
|
+
}
|
|
271
278
|
try {
|
|
272
279
|
const fn = getTrashFn(isElectron);
|
|
273
280
|
await fn(path);
|