(fileInfo)
| 5 | const walkUp = require('./walk-up-path'); |
| 6 | |
| 7 | async function cleanRemove(fileInfo) { |
| 8 | try { |
| 9 | await fs.stat(fileInfo.outputPath); |
| 10 | await fs.remove(fileInfo.outputPath); |
| 11 | let paths = walkUp(fileInfo.displayPath).map((thePath) => path.join(fileInfo.outputBasePath, thePath)); |
| 12 | |
| 13 | for (let thePath of paths) { |
| 14 | let childPaths = await fs.readdir(thePath); |
| 15 | if (childPaths.length > 0) { |
| 16 | return; |
| 17 | } |
| 18 | |
| 19 | await fs.remove(thePath); |
| 20 | } |
| 21 | } catch (err) { |
| 22 | // you tried to destroy a blueprint without first generating it |
| 23 | // instead of trying to read dirs that don't exist |
| 24 | // swallow error and carry on |
| 25 | if (err.code !== 'ENOENT') { |
| 26 | throw err; |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | module.exports = cleanRemove; |
no test coverage detected
searching dependent graphs…