| 384 | * @param folder folder to check |
| 385 | */ |
| 386 | export async function canReadWrite(folder: string): Promise<boolean> { |
| 387 | const testPath = path.join(folder, 'test'); |
| 388 | try { |
| 389 | const fd = await fs.promises.open(testPath, 'w'); |
| 390 | // Cleanup file after testing |
| 391 | await fd.close(); |
| 392 | await fs.promises.unlink(testPath); |
| 393 | return true; |
| 394 | } catch { |
| 395 | return false; |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | // Courtesy of https://www.paulirish.com/2009/random-hex-color-code-snippets/ |
| 400 | export function getRandomHexColor(): string { |