@dnax/core 0.45.4 → 0.45.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/package.json +1 -1
- package/utils/index.ts +28 -3
package/package.json
CHANGED
package/utils/index.ts
CHANGED
|
@@ -385,9 +385,24 @@ const password = {
|
|
|
385
385
|
};
|
|
386
386
|
|
|
387
387
|
const file = {
|
|
388
|
-
cp: async (
|
|
388
|
+
cp: async (
|
|
389
|
+
src: string,
|
|
390
|
+
des: string,
|
|
391
|
+
options: {
|
|
392
|
+
force?: boolean;
|
|
393
|
+
} = { force: false }
|
|
394
|
+
): Promise<{
|
|
395
|
+
size: number;
|
|
396
|
+
type: string;
|
|
397
|
+
lastModified: Date;
|
|
398
|
+
original_name: string | undefined;
|
|
399
|
+
name: string | undefined;
|
|
400
|
+
}> => {
|
|
389
401
|
return new Promise(async (resolve, reject) => {
|
|
390
402
|
try {
|
|
403
|
+
if ((await !fs.pathExists(des)) && !options?.force) {
|
|
404
|
+
reject("Already exist in destination");
|
|
405
|
+
}
|
|
391
406
|
await fs.copyFile(src, des);
|
|
392
407
|
let file = await Bun.file(des);
|
|
393
408
|
resolve({
|
|
@@ -402,10 +417,20 @@ const file = {
|
|
|
402
417
|
}
|
|
403
418
|
});
|
|
404
419
|
},
|
|
405
|
-
mv: async (
|
|
420
|
+
mv: async (
|
|
421
|
+
source: string,
|
|
422
|
+
destination: string,
|
|
423
|
+
options: {
|
|
424
|
+
overwrite?: boolean;
|
|
425
|
+
} = {
|
|
426
|
+
overwrite: false,
|
|
427
|
+
}
|
|
428
|
+
) => {
|
|
406
429
|
return new Promise(async (resolve, reject) => {
|
|
407
430
|
try {
|
|
408
|
-
await fs.move(source, destination
|
|
431
|
+
await fs.move(source, destination, {
|
|
432
|
+
overwrite: options?.overwrite,
|
|
433
|
+
});
|
|
409
434
|
resolve(true);
|
|
410
435
|
} catch (err: any) {
|
|
411
436
|
reject(err?.message);
|