(rootPath: string, defaultError?: string)
| 153 | } |
| 154 | |
| 155 | function validateRootPath(rootPath: string, defaultError?: string): string | undefined { |
| 156 | if (rootPath === "") return defaultError; // accept default value |
| 157 | rootPath = normalize(rootPath); |
| 158 | if (!canWriteRecursive(rootPath)) return "Path is not writable."; |
| 159 | if (!existsSync(rootPath)) return; |
| 160 | if (!statSync(rootPath).isDirectory()) return "File already exists."; |
| 161 | if (!canWrite(rootPath)) return "Directory is not writable."; |
| 162 | if (readdirSync(rootPath).length !== 0) return "Directory is not empty."; |
| 163 | } |
| 164 | |
| 165 | function inferTitle(rootPath = "."): string { |
| 166 | return basename(join(process.cwd(), rootPath)) |
no test coverage detected