1
0
mirror of https://github.com/TheFunny/ArisuAutoSweeper synced 2026-06-10 04:44:52 +00:00

Upload code

This commit is contained in:
2023-11-01 15:33:35 +08:00
commit 6860f2eb72
415 changed files with 50990 additions and 0 deletions
@@ -0,0 +1,35 @@
import type {CopyOptions} from 'fs-extra';
import fsExtra from 'fs-extra';
import {join, sep, normalize} from 'path';
export interface CopyToDirOptions {
successCallback?: (pathStr: string) => void;
filedCallback?: (pathStr: string, error: any) => void;
fsExtraOptions?: CopyOptions;
}
/**
*
* @param pathList
* @param targetDirPath
* @param options
*/
export async function copyFilesToDir(
pathList: string[],
targetDirPath: string,
options?: CopyToDirOptions | undefined,
) {
const {fsExtraOptions, successCallback, filedCallback} = options || {};
for (const pathStr of pathList) {
try {
await fsExtra.copy(
pathStr,
join(normalize(targetDirPath) + sep + pathStr.split(sep).pop()),
fsExtraOptions,
);
successCallback?.(pathStr);
} catch (err) {
filedCallback?.(pathStr, err);
}
}
}