* Copies one file to another. * @param {string} src The source file. * @param {string} dst The destination file. * @return {!Promise } A promise for the copied file's path.
(src, dst)
| 69 | * @return {!Promise<string>} A promise for the copied file's path. |
| 70 | */ |
| 71 | function copy(src, dst) { |
| 72 | return new Promise(function (fulfill, reject) { |
| 73 | const rs = fs.createReadStream(src) |
| 74 | rs.on('error', reject) |
| 75 | |
| 76 | const ws = fs.createWriteStream(dst) |
| 77 | ws.on('error', reject) |
| 78 | ws.on('close', () => fulfill(dst)) |
| 79 | |
| 80 | rs.pipe(ws) |
| 81 | }) |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Recursively copies the contents of one directory to another. |
no test coverage detected