(filepath: string)
| 75 | * Enforces official file extension and warns user if incorrect file detected. |
| 76 | */ |
| 77 | export function yamlExists(filepath: string): boolean { |
| 78 | const parsedPath = path.parse(filepath) |
| 79 | |
| 80 | if (parsedPath.ext !== '.yaml') { |
| 81 | return fatalError(`Invalid file extension: ${parsedPath.ext}`) |
| 82 | } |
| 83 | |
| 84 | if (!fs.existsSync(filepath)) { |
| 85 | const ymlPath = path.format({ |
| 86 | dir: parsedPath.dir, |
| 87 | name: parsedPath.name, |
| 88 | ext: '.yml', |
| 89 | }) |
| 90 | |
| 91 | if (fs.existsSync(ymlPath)) { |
| 92 | console.error(`Ignoring ${ymlPath} and using default. Please use ".yaml" extension instead.`) |
| 93 | } |
| 94 | |
| 95 | return false |
| 96 | } |
| 97 | |
| 98 | return true |
| 99 | } |
no test coverage detected