* Recursively adds a directory and all of its contents to this archive. * * @param {string} dirPath path to the directory to add. * @param {string=} zipPath path to the folder in the archive to add the * directory contents to. Defaults to the root folder. * @return {!Promise<?>} r
(dirPath, zipPath = '')
| 69 | * the operation is complete. |
| 70 | */ |
| 71 | addDir(dirPath, zipPath = '') { |
| 72 | return io.walkDir(dirPath).then((entries) => { |
| 73 | let archive = this.z_ |
| 74 | if (zipPath) { |
| 75 | archive = archive.folder(zipPath) |
| 76 | } |
| 77 | |
| 78 | let files = [] |
| 79 | entries.forEach((spec) => { |
| 80 | if (spec.dir) { |
| 81 | archive.folder(spec.path) |
| 82 | } else { |
| 83 | files.push(this.addFile(path.join(dirPath, spec.path), path.join(zipPath, spec.path))) |
| 84 | } |
| 85 | }) |
| 86 | |
| 87 | return Promise.all(files) |
| 88 | }) |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * @param {string} path File path to test for within the archive. |
no test coverage detected