fsPromises.cp(src, dest[, options])
稳定性: 1 - 实验
src<string> | <URL> 要复制的源路径。dest<string> | <URL> 要复制到的目标路径。options<Object>dereference<boolean> 取消引用符号链接。 默认值:false。errorOnExist<boolean> 当force为false且目标存在时,则抛出错误。 默认值:false。filter<Function> 过滤复制文件/目录的函数。 返回true则复制条目,返回false则忽略它。 也可以返回解决为true或false的Promise默认值:undefined。force<boolean> 覆盖现有的文件或目录。 如果将此设置为 false 并且目标存在,则复制操作将忽略错误。 使用errorOnExist选项更改此行为。 默认值:true。preserveTimestamps<boolean> 当为true时,则src的时间戳将被保留。 默认值:false。recursive<boolean> 递归地复制目录 默认值:falseverbatimSymlinks<boolean> 当为true时,则符号链接的路径解析将被跳过。 默认值:false
- 返回: <Promise> 成功时将使用
undefined履行。
将整个目录结构从 src 异步地复制到 dest,包括子目录和文件。
当将目录复制到另一个目录时,不支持 globs,并且行为类似于 cp dir1/ dir2/。
Stability: 1 - Experimental
src<string> | <URL> source path to copy.dest<string> | <URL> destination path to copy to.options<Object>dereference<boolean> dereference symlinks. Default:false.errorOnExist<boolean> whenforceisfalse, and the destination exists, throw an error. Default:false.filter<Function> Function to filter copied files/directories. Returntrueto copy the item,falseto ignore it. Can also return aPromisethat resolves totrueorfalseDefault:undefined.force<boolean> overwrite existing file or directory. The copy operation will ignore errors if you set this to false and the destination exists. Use theerrorOnExistoption to change this behavior. Default:true.preserveTimestamps<boolean> Whentruetimestamps fromsrcwill be preserved. Default:false.recursive<boolean> copy directories recursively Default:falseverbatimSymlinks<boolean> Whentrue, path resolution for symlinks will be skipped. Default:false
- Returns: <Promise> Fulfills with
undefinedupon success.
Asynchronously copies the entire directory structure from src to dest,
including subdirectories and files.
When copying a directory to another directory, globs are not supported and
behavior is similar to cp dir1/ dir2/.