| 477 | } |
| 478 | |
| 479 | export function createFolderForFile(file?: string): string | undefined { |
| 480 | try { |
| 481 | if (!file || !path.isAbsolute(file)) |
| 482 | return undefined; |
| 483 | |
| 484 | // Skip creation of paths with variables, we'll rely on them |
| 485 | // being created after resolving. |
| 486 | if (file?.includes("${")) { |
| 487 | return file; |
| 488 | } |
| 489 | |
| 490 | const folder = path.dirname(file); |
| 491 | if (!fs.existsSync(folder)) |
| 492 | mkDirRecursive(folder); |
| 493 | |
| 494 | return file; |
| 495 | } catch { |
| 496 | console.warn(`Ignoring invalid file path ${file}`); |
| 497 | return undefined; |
| 498 | } |
| 499 | } |
| 500 | |
| 501 | export function areSameFolder(folder1: string, folder2: string) { |
| 502 | // Trim any trailing path separators of either direction. |