Skip to content

Commit 4837714

Browse files
fix: Race condition when migrating to k6g (#570)
1 parent b6f2077 commit 4837714

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/main.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ import { ChildProcessWithoutNullStreams } from 'child_process'
7070
import { COPYFILE_EXCL } from 'constants'
7171

7272
import * as handlers from './handlers'
73+
import { existsSync } from 'fs'
7374

7475
if (process.env.NODE_ENV !== 'development') {
7576
// handle auto updates
@@ -119,6 +120,8 @@ initializeLogger()
119120

120121
// Used to convert `.json` files into the appropriate file extension for the Generator
121122
async function migrateJsonGenerator() {
123+
if (!existsSync(GENERATORS_PATH)) return
124+
122125
const items = await readdir(GENERATORS_PATH, { withFileTypes: true })
123126
const files = items.filter(
124127
(f) => f.isFile() && path.extname(f.name) === '.json'
@@ -256,13 +259,13 @@ const createWindow = async () => {
256259
app.whenReady().then(
257260
async () => {
258261
await createSplashWindow()
259-
await migrateJsonGenerator()
260262
await initSettings()
261263
appSettings = await getSettings()
262264
nativeTheme.themeSource = appSettings.appearance.theme
263265

264266
await sendReport(appSettings.telemetry.usageReport)
265267
await setupProjectStructure()
268+
await migrateJsonGenerator()
266269
await createWindow()
267270
},
268271
(error) => {

0 commit comments

Comments
 (0)