sdin
Version:
JavaScript package builder.
28 lines (27 loc) • 1.29 kB
TypeScript
import type { DeepReadingNode } from './read';
export type DeepCopyingNode = DeepReadingNode;
export type DeepCopyingHandler = (node: DeepCopyingNode, content: Buffer) => (string | Buffer) | Promise<string | Buffer>;
export type DeepCopyingFilter = (node: DeepCopyingNode) => boolean | Promise<boolean>;
export type DeepCopyingRename = (node: DeepCopyingNode, target: string) => string;
export type DeepCopyingRedirect = (node: DeepCopyingNode, target: string) => string;
export interface DeepCopyingOptions {
/** 需要扫描的代码路径 */
source: string;
/** 目标文件路径 */
target: string;
/** 转换文件内容的处理器 */
handler?: DeepCopyingHandler;
/** 过滤文件(为true才执行,否则跳过) */
filter?: DeepCopyingFilter;
/** 重定义目标文件名 */
rename?: DeepCopyingRename;
/** 重定向源文件路径 */
redirect?: DeepCopyingRedirect;
}
/**
* 深度遍历复制各个文件的信息
*
* - 文件名以_开头和结尾时,会自动修正(这是为了避开 git、npm 规则)
*/
export declare function deepCopy({ source, target, handler, filter, rename, redirect }: DeepCopyingOptions): Promise<void>;
export declare function deepCopyWithLoading(options: DeepCopyingOptions): Promise<void>;