UNPKG

fipy

Version:

A simple and easy package to copy files

43 lines (42 loc) 2.42 kB
/// <reference types="node" /> import { EventEmitter } from 'node:events'; import { FileCopySettings } from './fipy.settings'; export declare class FileCopy extends EventEmitter { private settings; constructor(settings: FileCopySettings); /** * Copies files from the source folder to the destination folder. Emits a fileCopied event for each file copied. * @param renameFunction A function that takes a file name as an argument and returns a new file name. If not provided, the file name is not changed. * @emits fileCopied An event that is emitted for each file copied. The event emits the source file and the destination file. * @emits error An event that is emitted if an error occurs. The event emits the error message. */ copyFiles(renameFunction?: (file: string) => string): void; /** * Moves files from the source folder to the destination folder. Emits a fileCopied and a fileDeleted event for each file moved. * @emits fileCopied An event that is emitted for each file copied. The event emits the source file and the destination file. * @emits fileDeleted An event that is emitted for each file deleted. The event emits the source file. * @emits error An event that is emitted if an error occurs. The event emits the error message. */ moveFiles(renameFunction?: (file: string) => string): void; private checkSourceFolder; private checkDestinationFolder; private copyFile; private getFilesToCopy; private getFilesRecursive; private getFiles; /** * Adds a listener for the fileCopied event. * @param listener The callback function to call when the event is emitted. The callback function takes two arguments: file and destinationFile. */ on(event: 'fileCopied', listener: (file: string, destinationFile: string) => void): this; /** * Adds a listener for the fileDeleted event. * @param listener The callback function to call when the event is emitted. The callback function takes one argument: file. */ on(event: 'fileDeleted', listener: (file: string) => void): this; /** * Adds a listener for the error event. * @param listener The callback function to call when the event is emitted. The callback function takes one argument: error. */ on(event: 'error', listener: (error: string) => void): this; }