diff --git a/LICENSE b/LICENSE index 18392b1d6a1a5f..4b1135ead791d5 100644 --- a/LICENSE +++ b/LICENSE @@ -1584,3 +1584,28 @@ The externally maintained libraries used by Node.js are: OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ + +- fs-extra, located at lib/internal/fs/copy, is licensed as follows: + """ + (The MIT License) + + Copyright (c) 2011-2021 JP Richardson + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the 'Software'), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + """ diff --git a/doc/api/errors.md b/doc/api/errors.md index d7df19cf7f0caa..48629508d76997 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -1111,6 +1111,74 @@ added: v14.0.0 Used when a feature that is not available to the current platform which is running Node.js is used. + +### `ERR_FS_COPY_DIR_TO_NON_DIR` + + +An attempt was made to copy a directory to a non-directory (file, symlink, +etc.) using [`fs.copy()`][]. + + +### `ERR_FS_COPY_EEXIST` + + +An attempt was made to copy over a file that already existed with +[`fs.copy()`][], with the `overwrite` and `errorOnExist` set to `true`. + + +### `ERR_FS_COPY_FIFO_PIPE` + + +An attempt was made to copy a named pipe with [`fs.copy()`][]. + + +### `ERR_FS_COPY_NON_DIR_TO_DIR` + + +An attempt was made to copy a non-directory (file, symlink, etc.) to a directory +using [`fs.copy()`][]. + + +### `ERR_FS_COPY_SOCKET` + + +An attempt was made to copy to a socket with [`fs.copy()`][]. + + +### `ERR_FS_COPY_SYMLINK_TO_SUBDIRECTORY` + + +When using [`fs.copy()`][], a symlink in `dest` pointed to a subdirectory +of `src`. + + +### `ERR_FS_COPY_TO_SUBDIRECTORY` + + +When using [`fs.copy()`][], `dest` pointed to a subfolder in `src`. + + +### `ERR_FS_COPY_UNKNOWN` + + +An attempt was made to copy to an unknown file type with [`fs.copy()`][]. + ### `ERR_FS_EISDIR` @@ -2818,6 +2886,7 @@ The native call from `process.cpuUsage` could not be processed. [`dgram.remoteAddress()`]: dgram.md#dgram_socket_remoteaddress [`errno`(3) man page]: https://man7.org/linux/man-pages/man3/errno.3.html [`fs.Dir`]: fs.md#fs_class_fs_dir +[`fs.copy()`]: fs.md#fs_fs_copy_src_dest_options_callback [`fs.readFileSync`]: fs.md#fs_fs_readfilesync_path_options [`fs.readdir`]: fs.md#fs_fs_readdir_path_options_callback [`fs.symlink()`]: fs.md#fs_fs_symlink_target_path_type_callback diff --git a/doc/api/fs.md b/doc/api/fs.md index ab5d7f08e1082f..debb54777ccda3 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1752,6 +1752,33 @@ through any other `fs` operation may lead to undefined behavior. See the POSIX close(2) documentation for more detail. +### `fs.copy(src, dest[, options], callback)` + + +* `src` {string|Buffer|URL} source path to copy. +* `dest` {string|Buffer|URL} destination path to copy to. +* `options` {Object|Function} + * `dereference` {boolean} dereference symlinks. **Default:** `false`. + * `errorOnExist` {boolean} when `overwrite` is `false`, and the destination + exists, throw an error. **Default:** `false`. + * `filter` {Function} Function to filter copied files/directories. Return + `true` to copy the item, `false` to ignore it. **Default:** `undefined` + * `overwrite` {boolean} overwrite existing file or directory. _The copy + operation will ignore errors if you set this to false and the destination + exists. Use the `errorOnExist` option to change this behavior. + **Default:** `true`. + * `preserveTimestamps` {boolean} When `true` timestamps from `src` will + be preserved. **Default:** `false`. +* `callback` {Function} + +Asynchronously copies the entire directory structure from `src` to `dest`, +including subdirectories and files. + +If a function is provided for `options`, it will be used as the `filter` +parameter. + ### `fs.copyFile(src, dest[, mode], callback)`