* Determine if this is the first run of the application by checking for the existence of a specific file. * * @returns true if this is the first run, false otherwise
()
| 57 | * @returns true if this is the first run, false otherwise |
| 58 | */ |
| 59 | function checkAndMarkFirstRun(): boolean { |
| 60 | const configPath = getConfigPath(); |
| 61 | |
| 62 | try { |
| 63 | if (fs.existsSync(configPath)) { |
| 64 | return false; |
| 65 | } |
| 66 | |
| 67 | const firstRunFolder = path.dirname(configPath); |
| 68 | if (!fs.existsSync(firstRunFolder)) { |
| 69 | fs.mkdirSync(firstRunFolder); |
| 70 | } |
| 71 | |
| 72 | fs.writeFileSync(configPath, ''); |
| 73 | } catch (err) { |
| 74 | logError( |
| 75 | 'checkAndMarkFirstRun', |
| 76 | 'Unable to write firstRun file', |
| 77 | toError(err), |
| 78 | ); |
| 79 | } |
| 80 | |
| 81 | return true; |
| 82 | } |
no test coverage detected