fs.cp(src, dest[, options], callback)
将整个目录结构从 src
异步地复制到 dest
,包括子目录和文件。
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> whenforce
isfalse
, and the destination exists, throw an error. Default:false
.filter
<Function> Function to filter copied files/directories. Returntrue
to copy the item,false
to ignore it. Can also return aPromise
that resolves totrue
orfalse
Default: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 theerrorOnExist
option to change this behavior. Default:true
.preserveTimestamps
<boolean> Whentrue
timestamps fromsrc
will be preserved. Default:false
.recursive
<boolean> copy directories recursively Default:false
verbatimSymlinks
<boolean> Whentrue
, path resolution for symlinks will be skipped. Default:false
callback
<Function>
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/
.