| Conditions | 3 |
| Total Lines | 17 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import {existsSync, mkdirSync} from 'fs' |
||
| 3 | |||
| 4 | /** |
||
| 5 | * Ensure the given path exists, then return a string or false when failed. |
||
| 6 | * @param path |
||
| 7 | */ |
||
| 8 | async function ensureDirectoryExists(path: string): Promise<false | string> { |
||
| 9 | if (!existsSync(path)) { |
||
| 10 | try { |
||
| 11 | await mkdirSync(path, {mode: 0o755}) |
||
| 12 | return path |
||
| 13 | } catch (e) { |
||
| 14 | error(e.message) |
||
| 15 | return false |
||
| 16 | } |
||
| 17 | } |
||
| 18 | |||
| 19 | return path |
||
| 20 | } |
||
| 24 | } |