* For each item in `this.path`, creates a directory at the path or verify * that the path exists as a directory.
()
| 204 | * that the path exists as a directory. |
| 205 | */ |
| 206 | protected async createOrVerifyDirectory() { |
| 207 | const paths = Array.isArray(this.path) ? this.path : [this.path]; |
| 208 | for (const path of paths) { |
| 209 | try { |
| 210 | await mkdir(path); |
| 211 | } catch (e) { |
| 212 | if (e.code === 'EEXIST') { |
| 213 | if ((await stat(path)).isFile()) { |
| 214 | throw new Error( |
| 215 | `Path ${path} exists as a file. The path must be ` + |
| 216 | `nonexistent or point to a directory.`); |
| 217 | } |
| 218 | // else continue, the directory exists |
| 219 | } else { |
| 220 | throw e; |
| 221 | } |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | export const nodeFileSystemRouter = (url: string|string[]) => { |