From 294f77018091807038509edd0fb06d32f9b4af65 Mon Sep 17 00:00:00 2001 From: idillon Date: Tue, 17 Sep 2024 16:08:47 -0400 Subject: [PATCH] Fix: types in client/src/driver/BitbakeDriver.ts --- client/src/driver/BitbakeDriver.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/client/src/driver/BitbakeDriver.ts b/client/src/driver/BitbakeDriver.ts index 0d5bc5d5e..ef0312ab2 100644 --- a/client/src/driver/BitbakeDriver.ts +++ b/client/src/driver/BitbakeDriver.ts @@ -40,7 +40,7 @@ export class BitbakeDriver { }) } - private getBuildConfig (property: keyof BitbakeBuildConfigSettings): string | NodeJS.Dict | undefined { + getBuildConfig (property: keyof BitbakeBuildConfigSettings): string | NodeJS.Dict | undefined { return getBuildSetting(this.bitbakeSettings, this.activeBuildConfiguration, property) } @@ -80,14 +80,16 @@ export class BitbakeDriver { prepareCommand (command: string): { shell: string - shellEnv: Record + shellEnv: NodeJS.Dict script: string workingDirectory: string | undefined } { const shell = process.env.SHELL ?? '/bin/sh' - const shellEnv = this.getBuildConfig('shellEnv') + const tempShellEnv = this.getBuildConfig('shellEnv') + const shellEnv = typeof tempShellEnv === 'object' ? tempShellEnv : {} const script = this.composeBitbakeScript(command) - const workingDirectory = this.getBuildConfig('workingDirectory') ?? '.' + const tempWorkingDirectory = this.getBuildConfig('workingDirectory') + const workingDirectory = typeof tempWorkingDirectory === 'string' ? tempWorkingDirectory : '.' return { shell, shellEnv, script, workingDirectory } } @@ -130,7 +132,8 @@ export class BitbakeDriver { return false } - if ((this.getBuildConfig('workingDirectory') != null) && !fs.existsSync(this.getBuildConfig('workingDirectory'))) { + const workingDirectory = this.getBuildConfig('workingDirectory') + if (typeof workingDirectory === 'string' && !fs.existsSync(workingDirectory)) { // If it is not defined, then we will use the workspace folder which is always valid clientNotificationManager.showBitbakeSettingsError('Working directory does not exist.') return false