| 216 | } |
| 217 | |
| 218 | function findFilesInFolder(oldPath, newPath, opts) { |
| 219 | const { undo, verbose } = opts |
| 220 | const files = [] |
| 221 | const allFiles = walk(oldPath, { includeBasePath: true, directories: false }) |
| 222 | for (const filePath of allFiles) { |
| 223 | const newFilePath = filePath.replace(oldPath, newPath) |
| 224 | const oldHref = makeHref(CONTENT_ROOT, undo ? newFilePath : filePath) |
| 225 | const newHref = makeHref(CONTENT_ROOT, undo ? filePath : newFilePath) |
| 226 | files.push([filePath, newFilePath, oldHref, newHref]) |
| 227 | } |
| 228 | if (verbose) { |
| 229 | console.log(chalk.yellow(`Found ${files.length} files within ${oldPath}`)) |
| 230 | } |
| 231 | return files |
| 232 | } |
| 233 | |
| 234 | function makeHref(root, filePath) { |
| 235 | const nameSplit = path.relative(root, filePath).split(path.sep) |