Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update eslint #327

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
5e7ce0e
chore(deps-dev): bump eslint-config-standard-with-typescript
dependabot[bot] Jul 1, 2024
b18ce7c
chore(deps-dev): bump eslint-plugin-import from 2.28.1 to 2.29.1
dependabot[bot] Aug 1, 2024
3e36b93
chore(deps-dev): bump @types/vscode from 1.83.1 to 1.92.0
dependabot[bot] Aug 2, 2024
7f10800
chore(deps-dev): bump typescript from 5.2.2 to 5.5.4
dependabot[bot] Aug 2, 2024
a8cf826
Chore: Remove unused eslint plugins
WilsonZiweiWang Aug 27, 2024
a03c50c
Chore: Reindent package.json
idillon-sfl Sep 16, 2024
891e832
Chore: Uninstall eslint 8
idillon-sfl Sep 16, 2024
7747fe3
Chore: Install eslint 9.0
idillon-sfl Sep 17, 2024
b6982bf
Chore: Install and setup @tony.ganchev/eslint-plugin-header
idillon-sfl Sep 17, 2024
f0f2610
Fix: all 'Unused eslint-disable directive'
idillon-sfl Sep 17, 2024
2ffa432
Fix: eslint issues on server/src/tree-sitter/analyzer.ts
idillon-sfl Sep 17, 2024
a09c5c4
Fix: eslint issues on server/src/connectionHandlers/onHover.ts
idillon-sfl Sep 17, 2024
010a96e
Fix: eslint issues on server/src/completions/snippet-utils.ts
idillon-sfl Sep 17, 2024
b620095
Fix: eslint issues on server/src/__tests__/onReference.test.ts
idillon-sfl Sep 17, 2024
797b9dc
Fix: eslint issues on server/src/__tests__/completions.test.ts
idillon-sfl Sep 17, 2024
db7e33a
Fix: eslint issues on server/src/BitBakeDocScanner.ts
idillon-sfl Sep 17, 2024
00ca3b5
Fix: eslint issues on integration-tests/src/tests/rename.test.ts
idillon-sfl Sep 17, 2024
19f2f92
Fix: eslint issues on integration-tests/src/tests/references.test.ts
idillon-sfl Sep 17, 2024
5a30f24
Fix eslint issues on integration-tests/src/tests/bitbake-parse.test.ts
idillon-sfl Sep 17, 2024
4f29461
Fix: eslint errors on client/src/utils/ProcessUtils.ts
idillon-sfl Sep 17, 2024
37fc8c3
Fix: eslint issues on client/src/ui/BitbakeTerminalProfile.ts
idillon-sfl Sep 17, 2024
5dc1c3b
Fix: eslint issues on client/src/ui/BitbakeTerminalLinkProvider.ts
idillon-sfl Sep 17, 2024
d3b1777
Fix: eslint issues on client/src/ui/BitbakeTaskProvider.ts
idillon-sfl Sep 17, 2024
5816646
Fix: eslint issues on client/src/ui/BitbakeRecipesView.ts
idillon-sfl Sep 17, 2024
79a30f8
Fix: eslint issues on server/src/server.ts
idillon-sfl Sep 17, 2024
fcc3b8a
Fix: eslint issues on server/src/completions/spdx-licenses.ts
idillon-sfl Sep 17, 2024
29f2cf5
Refactor: Replace PathInfo for path.ParsedPath
idillon-sfl Sep 17, 2024
cd1fced
Fix: eslint issues on client/src/language/middlewareRename.ts
idillon-sfl Sep 17, 2024
5794fa2
Fix: eslint issues on client/src/language/middlewareDefinition.ts
idillon-sfl Sep 17, 2024
32d5606
Fix: eslint issues on client/src/language/diagnosticsSupport.ts
idillon-sfl Sep 17, 2024
3d4a7ac
Fix: eslint issues on client/src/language/codeActionProvider.ts
idillon-sfl Sep 17, 2024
a89ce58
Fix: eslint issues on client/src/language/EmbeddedLanguageDocsManager.ts
idillon-sfl Sep 17, 2024
0b527e3
Fix: eslint issues on client/src/extension.ts
idillon-sfl Sep 17, 2024
4f3527f
Fix: eslint issues on client/src/driver/BitBakeProjectScanner.ts
idillon-sfl Sep 17, 2024
96f0e80
Fix: eslint issues on server/src/__tests__/fixtures/fixtures.ts
idillon-sfl Sep 17, 2024
b882cb8
Fix: eslint issues on client/src/ui/BitbakeCommands.ts
idillon-sfl Sep 17, 2024
9ac8507
Fix: eslint issues on client/src/lib/src/types/requests.ts
idillon-sfl Sep 17, 2024
3769fd4
Fix: eslint issues on client/src/lib/src/BitbakeSettings.ts
idillon-sfl Sep 17, 2024
5359e0f
Fix: eslint issues on client/src/driver/BitbakeEnvScanner.ts
idillon-sfl Sep 17, 2024
8a5bf08
Fix: eslint issues on client/src/driver/BitbakeDriver.ts
idillon-sfl Sep 17, 2024
6db164f
Fix: eslint issues on client/src/lib/src/__tests__/utils/output-logge…
idillon-sfl Sep 17, 2024
38c4fb4
Fix: eslint issues on client/src/__tests__/unit-tests/driver/BitbakeE…
idillon-sfl Sep 17, 2024
ec967b4
Fix: eslint issues on client/src/__tests__/unit-tests/driver/eSDKMode…
idillon-sfl Sep 17, 2024
0cb55fb
Fix: eslint issues on client/src/__tests__/unit-tests/ui/bitbake-comm…
idillon-sfl Sep 17, 2024
8d4e48d
Fix: eslint issues on client/src/__tests__/unit-tests/ui/bitbake-reci…
idillon-sfl Sep 17, 2024
e5fec7c
Fix: eslint issues on client/src/__tests__/unit-tests/ui/bitbake-term…
idillon-sfl Sep 17, 2024
3127f59
Fix: eslint issues on client/src/__tests__/unit-tests/ui/devtool-work…
idillon-sfl Sep 17, 2024
2428423
Fix: eslint issues on client/src/utils/JSONFile.ts
idillon-sfl Sep 17, 2024
cbc2568
Fix: types in client/src/driver/BitbakeDriver.ts
idillon-sfl Sep 17, 2024
6b49f00
Chore: Install @types/find
idillon-sfl Sep 17, 2024
706b02f
Fix: Type checking of hostWorkdir in resolveCorrespondingPath
idillon-sfl Sep 17, 2024
ddae350
Chore: Update vscode engine (1.92.0)
idillon-sfl Sep 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"url": "https://github.com/yoctoproject/vscode-bitbake.git"
},
"engines": {
"vscode": "^1.75.0"
"vscode": "^1.92.0"
},
"dependencies": {
"find": "^0.3.0",
Expand Down
13 changes: 7 additions & 6 deletions client/src/__tests__/unit-tests/driver/BitbakeESDK.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { copyBitbakeSettings, generateCPPProperties, generateTasksDefinitions }
import { type BitbakeSettings } from '../../../lib/src/BitbakeSettings'

import * as JSONFile from '../../../utils/JSONFile'
import * as LanguageClient from '../../../language/languageClient'
import * as BitBakeLanguageClient from '../../../language/languageClient'
import { LanguageClient } from 'vscode-languageclient/node'
import { BitBakeProjectScanner } from '../../../driver/BitBakeProjectScanner'

describe('Bitbake ESDK Test Suite', () => {
const workspace = {
Expand Down Expand Up @@ -93,7 +95,6 @@ describe('Bitbake ESDK Test Suite', () => {
{
name: 'should not be overwritten',
browse: {
// eslint-disable-next-line no-template-curly-in-string
path: ['${workspaceFolder}/**']
}
}
Expand All @@ -103,11 +104,11 @@ describe('Bitbake ESDK Test Suite', () => {
loadJsonMock.mockReturnValueOnce(originalConfig)
const saveJsonMock = jest.spyOn(JSONFile, 'saveJsonFile').mockImplementation(() => {})

const bitBakeProjectScannerMock = { resolveContainerPath: jest.fn().mockImplementation((arg) => arg) } as any
const clientMock = jest.fn() as any
const getVariableValueMock = jest.spyOn(LanguageClient, 'getVariableValue')
const bitBakeProjectScannerMock = { resolveContainerPath: jest.fn().mockImplementation((arg) => arg) } as unknown as BitBakeProjectScanner
const clientMock = jest.fn() as unknown as LanguageClient
const getVariableValueMock = jest.spyOn(BitBakeLanguageClient, 'getVariableValue')
getVariableValueMock.mockImplementation(
async (client, variable, recipe) => {
async (client, variable) => {
if (variable === 'STAGING_BINDIR_TOOLCHAIN') {
return '/opt'
}
Expand Down
2 changes: 0 additions & 2 deletions client/src/__tests__/unit-tests/driver/bitbake-driver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ describe('BitbakeDriver Tests', () => {
})

it('should produce a valid crops docker run script', () => {
/* eslint-disable no-template-curly-in-string */
const driver = new BitbakeDriver()
driver.loadSettings({
commandWrapper: 'docker run --rm -it -v ${workspaceFolder}:/workdir crops/poky --workdir=/workdir /bin/bash -c',
Expand Down Expand Up @@ -111,7 +110,6 @@ describe('BitbakeDriver Tests', () => {
})

it('should compose bitbake command for scanning recipe environment', () => {
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
const bitbakeTaskDefinition = {
recipes: ['recipe1'],
options: {
Expand Down
21 changes: 11 additions & 10 deletions client/src/__tests__/unit-tests/driver/eSDKMode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@

import { BitBakeProjectScanner } from '../../../driver/BitBakeProjectScanner'
import { BitbakeDriver } from '../../../driver/BitbakeDriver'
import { type BitbakeSettings } from '../../../lib/src/BitbakeSettings'
import * as BitbakeTerminal from '../../../ui/BitbakeTerminal'
import * as ProcessUtils from '../../../utils/ProcessUtils'
import { bitbakeESDKMode, setBitbakeESDKMode } from '../../../driver/BitbakeESDK'
import { clientNotificationManager } from '../../../ui/ClientNotificationManager'
import { SpawnSyncReturns } from 'child_process'
import { IPty } from 'node-pty'

// Yocto's eSDKs contain devtool but not bitbake. These tests ensure we can still provide devtool functionalities without bitbake.
describe('Devtool eSDK Mode Test Suite', () => {
Expand All @@ -23,10 +24,10 @@ describe('Devtool eSDK Mode Test Suite', () => {
const bitBakeProjectScanner = new BitBakeProjectScanner(bitbakeDriver)
setBitbakeESDKMode(true)

const scanAvailableLayersSpy = jest.spyOn(bitBakeProjectScanner as any, 'scanAvailableLayers').mockImplementation(async () => {})
const scanForRecipesSpy = jest.spyOn(bitBakeProjectScanner as any, 'scanForRecipes').mockImplementation(async () => {})
const parseAllRecipesSpy = jest.spyOn(bitBakeProjectScanner as any, 'parseAllRecipes').mockImplementation(async () => {})
const scanDevtoolWorkspaces = jest.spyOn(bitBakeProjectScanner as any, 'scanDevtoolWorkspaces').mockImplementation(async () => {})
const scanAvailableLayersSpy = jest.spyOn(bitBakeProjectScanner, 'scanAvailableLayers').mockImplementation(async () => {})
const scanForRecipesSpy = jest.spyOn(bitBakeProjectScanner, 'scanForRecipes').mockImplementation(async () => {})
const parseAllRecipesSpy = jest.spyOn(bitBakeProjectScanner, 'parseAllRecipes').mockImplementation(async () => {})
const scanDevtoolWorkspaces = jest.spyOn(bitBakeProjectScanner, 'scanDevtoolWorkspaces').mockImplementation(async () => {})

await bitBakeProjectScanner.rescanProject()

Expand All @@ -38,22 +39,22 @@ describe('Devtool eSDK Mode Test Suite', () => {

it('can detect eSDK mode', async () => {
const bitbakeDriver = new BitbakeDriver()
const bitbakeSettings: BitbakeSettings = {
const bitbakeSettings: Record<string, unknown> = {
pathToBitbakeFolder: __dirname,
workingDirectory: __dirname,
commandWrapper: '',
pathToEnvScript: 'fakeEnvScript',
pathToBuildFolder: 'nonexistent'
}
bitbakeDriver.loadSettings(bitbakeSettings, __dirname)
const bitbakeTerminalSpy = jest.spyOn(BitbakeTerminal, 'runBitbakeTerminalCustomCommand').mockImplementation(async () => undefined as any)
const bitbakeTerminalSpy = jest.spyOn(BitbakeTerminal, 'runBitbakeTerminalCustomCommand').mockImplementation(async () => (undefined as unknown as Promise<IPty>))
const bitbakeExecutionSpy = jest.spyOn(ProcessUtils, 'finishProcessExecution')
clientNotificationManager.showBitbakeSettingsError = jest.fn()

bitbakeExecutionSpy.mockReturnValueOnce(Promise.resolve({
status: 1,
stdout: '/tmp/devtool\r\nbitbake not found'
} as any))
} as unknown as Promise<SpawnSyncReturns<Buffer>>))
let sane = await bitbakeDriver.checkBitbakeSettingsSanity()
expect(sane).toStrictEqual(true)
expect(bitbakeTerminalSpy).toHaveBeenCalledWith(expect.anything(), expect.stringContaining('which'), expect.anything(), expect.anything())
Expand All @@ -62,15 +63,15 @@ describe('Devtool eSDK Mode Test Suite', () => {
bitbakeExecutionSpy.mockReturnValueOnce(Promise.resolve({
status: 0,
stdout: '/tmp/devtool\r\n/tmp/bitbake'
} as any))
} as unknown as Promise<SpawnSyncReturns<Buffer>>))
sane = await bitbakeDriver.checkBitbakeSettingsSanity()
expect(sane).toStrictEqual(true)
expect(bitbakeESDKMode).toStrictEqual(false)

bitbakeExecutionSpy.mockReturnValueOnce(Promise.resolve({
status: 1,
stdout: 'error'
} as any))
} as unknown as Promise<SpawnSyncReturns<Buffer>>))
sane = await bitbakeDriver.checkBitbakeSettingsSanity()
expect(sane).toStrictEqual(false)
})
Expand Down
23 changes: 13 additions & 10 deletions client/src/__tests__/unit-tests/ui/bitbake-commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,31 @@
* ------------------------------------------------------------------------------------------ */

import * as vscode from 'vscode'
import type childProcess from 'child_process'
import { BitbakeWorkspace } from '../../../ui/BitbakeWorkspace'
import { BitBakeProjectScanner } from '../../../driver/BitBakeProjectScanner'
import { BitbakeDriver } from '../../../driver/BitbakeDriver'
import { registerDevtoolCommands } from '../../../ui/BitbakeCommands'
import { clientNotificationManager } from '../../../ui/ClientNotificationManager'
import * as BitbakeTerminal from '../../../ui/BitbakeTerminal'
import * as ProcessUtils from '../../../utils/ProcessUtils'
import { LanguageClient } from 'vscode-languageclient/node'
import { IPty } from 'node-pty'

jest.mock('vscode')

function mockExtensionContext (bitBakeProjectScanner: BitBakeProjectScanner): any {
function mockExtensionContext (bitBakeProjectScanner: BitBakeProjectScanner): (...args: unknown[]) => unknown {
const bitbakeWorkspace = new BitbakeWorkspace()
const contextMock: vscode.ExtensionContext = {
subscriptions: {
push: jest.fn()
}
} as any
const clientMock = jest.fn() as any
} as unknown as vscode.ExtensionContext
const clientMock = jest.fn() as unknown as LanguageClient

let ideSDKCommand: any
let ideSDKCommand = () => {}
vscode.commands.registerCommand = jest.fn().mockImplementation(
(command: string, callback: (...args: any[]) => any, thisArg?: any): void => {
(command: string, callback: (...args: unknown[]) => unknown): void => {
if (command === 'bitbake.devtool-ide-sdk') {
ideSDKCommand = callback
}
Expand Down Expand Up @@ -57,8 +60,8 @@ describe('Devtool ide-sdk command', () => {
}
const ideSDKCommand = mockExtensionContext(bitBakeProjectScanner)

jest.spyOn(BitbakeTerminal, 'runBitbakeTerminalCustomCommand').mockReturnValue(undefined as any)
jest.spyOn(ProcessUtils, 'finishProcessExecution').mockReturnValue({ status: 1 } as any)
jest.spyOn(BitbakeTerminal, 'runBitbakeTerminalCustomCommand').mockReturnValue(undefined as unknown as Promise<IPty>)
jest.spyOn(ProcessUtils, 'finishProcessExecution').mockReturnValue({ status: 1 } as unknown as Promise<childProcess.SpawnSyncReturns<Buffer>>)

clientNotificationManager.showSDKUnavailableError = jest.fn()
await ideSDKCommand('busybox')
Expand All @@ -74,10 +77,10 @@ describe('Devtool ide-sdk command', () => {
}
const ideSDKCommand = mockExtensionContext(bitBakeProjectScanner)

const commandSpy = jest.spyOn(BitbakeTerminal, 'runBitbakeTerminalCustomCommand').mockReturnValue(undefined as any)
jest.spyOn(ProcessUtils, 'finishProcessExecution').mockReturnValue({ status: 0 } as any)
const commandSpy = jest.spyOn(BitbakeTerminal, 'runBitbakeTerminalCustomCommand').mockReturnValue(undefined as unknown as Promise<IPty>)
jest.spyOn(ProcessUtils, 'finishProcessExecution').mockReturnValue({ status: 0 } as unknown as Promise<childProcess.SpawnSyncReturns<Buffer>>)

jest.spyOn(vscode.window, 'showInformationMessage').mockReturnValue({ then: jest.fn() } as any)
jest.spyOn(vscode.window, 'showInformationMessage').mockReturnValue({ then: jest.fn() } as unknown as Thenable<vscode.MessageItem | undefined>)
await ideSDKCommand('busybox')
expect(commandSpy).toHaveBeenCalledWith(expect.anything(), 'devtool ide-sdk -i code busybox core-image-minimal -t [email protected]', expect.anything())
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ describe('BitbakeDriver Recipes View', () => {
const bitBakeProjectScanner = new BitBakeProjectScanner(new BitbakeDriver())
void bitbakeWorkspace.addActiveRecipe('base-files') // The promise is the memento which is under mock

const contextMock: vscode.ExtensionContext = {
const contextMock = {
subscriptions: {
push: jest.fn()
}
} as any
} as unknown as vscode.ExtensionContext

const scanResult: BitbakeScanResult = {
_recipes: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { BitbakeTerminalLinkProvider } from '../../../ui/BitbakeTerminalLinkProv
import { type BitBakeProjectScanner } from '../../../driver/BitBakeProjectScanner'

describe('BitbakeTerminalLinkProvider', () => {
const bitBakeProjectScanner: BitBakeProjectScanner = jest.fn() as any
const bitBakeProjectScanner = jest.fn() as unknown as BitBakeProjectScanner
const linkProvider: BitbakeTerminalLinkProvider = new BitbakeTerminalLinkProvider(bitBakeProjectScanner)

function mockScanner (): void {
Expand All @@ -34,18 +34,16 @@ describe('BitbakeTerminalLinkProvider', () => {
})

it('should return an empty array if container paths resolution is not needed', async () => {
const context: vscode.TerminalLinkContext = { line: 'some line without absolute links ./abcd;(123)' } as any
const token: vscode.CancellationToken = undefined as any
const context = { line: 'some line without absolute links ./abcd;(123)' } as unknown as vscode.TerminalLinkContext

const result = await linkProvider.provideTerminalLinks(context, token)
const result = await linkProvider.provideTerminalLinks(context)

expect(result).toEqual([])
})

it('should return an array of TerminalLinks for container paths', async () => {
const context: vscode.TerminalLinkContext = { line: 'some line "/path/to/file:123" with a link' } as any
const token: vscode.CancellationToken = undefined as any
const result = await linkProvider.provideTerminalLinks(context, token)
const context = { line: 'some line "/path/to/file:123" with a link' } as unknown as vscode.TerminalLinkContext
const result = await linkProvider.provideTerminalLinks(context)
expect(result).toHaveLength(1)
expect(result[0].startIndex).toBe(11)
expect(result[0].length).toBe(13)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ describe('Devtool Worskapces View', () => {
})

it('should list devtool workspaces', (done) => {
const contextMock: vscode.ExtensionContext = {
const contextMock = {
subscriptions: {
push: jest.fn()
}
} as any
} as unknown as vscode.ExtensionContext

const scanResult: BitbakeScanResult = {
_recipes: [{
Expand Down
15 changes: 7 additions & 8 deletions client/src/driver/BitBakeProjectScanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import type {
DevtoolWorkspaceInfo,
ElementInfo,
LayerInfo,
PathInfo
} from '../lib/src/types/BitbakeScanResult'

import { type BitbakeDriver } from './BitbakeDriver'
Expand Down Expand Up @@ -123,7 +122,7 @@ export class BitBakeProjectScanner {
void this._languageClient?.sendNotification(NotificationMethod.ScanComplete, this._bitbakeScanResult)
this.onChange.emit(BitBakeProjectScanner.EventType.SCAN_COMPLETE, this._bitbakeScanResult)
} catch (error) {
logger.error(`scanning of project is aborted: ${error as any}`)
logger.error(`scanning of project is aborted: ${error}`)
this.onChange.emit(BitBakeProjectScanner.EventType.SCAN_COMPLETE, this._bitbakeScanResult)
}

Expand Down Expand Up @@ -204,7 +203,7 @@ export class BitBakeProjectScanner {
this._bitbakeScanResult._confFiles = this.searchFiles(this._confFileExtension)
}

private async scanAvailableLayers (): Promise<void> {
public async scanAvailableLayers (): Promise<void> {
this._bitbakeScanResult._layers = new Array < LayerInfo >()
this.containerMountPoint = undefined

Expand Down Expand Up @@ -239,8 +238,8 @@ export class BitBakeProjectScanner {
if (this.containerMountPoint === undefined && !hostToContainer) {
// Should only be called through scanAvailableLayers()
const hostWorkdir = this.bitbakeDriver?.getBuildConfig('workingDirectory')
if (hostWorkdir === undefined) {
throw new Error('hostWorkdir is undefined')
if (typeof hostWorkdir !== 'string') {
throw new Error('hostWorkdir is not a string')
}
await this.scanContainerMountPoint(inputPath, hostWorkdir)
}
Expand Down Expand Up @@ -296,7 +295,7 @@ You should adjust your docker volumes to use the same URIs as those present on y
try {
const files = find.fileSync(new RegExp(`.${pattern}$`), layer.path)
for (const file of files) {
const pathObj: PathInfo = path.parse(file)
const pathObj: path.ParsedPath = path.parse(file)

const element: ElementInfo = {
name: pathObj.name,
Expand Down Expand Up @@ -390,7 +389,7 @@ You should adjust your docker volumes to use the same URIs as those present on y
this._bitbakeScanResult._overrides = output.match(outerReg)?.[1].split(':') ?? []
}

private async scanDevtoolWorkspaces (): Promise<void> {
public async scanDevtoolWorkspaces (): Promise<void> {
this._bitbakeScanResult._workspaces = new Array < DevtoolWorkspaceInfo >()
const output = await this.executeBitBakeCommand('devtool status')
const regex = /^([^\s]+):\s([^\s]+)(?:\s\([^\s]+\))?$/gm
Expand Down Expand Up @@ -471,7 +470,7 @@ You should adjust your docker volumes to use the same URIs as those present on y

for (const matchInner of match[0].matchAll(innerReg)) {
if (recipe.appends === undefined) {
recipe.appends = new Array < PathInfo >()
recipe.appends = new Array < path.ParsedPath >()
}
if (bbappendVersionMatches(recipeVersion, recipe.version)) {
const resolvedPath = await this.resolveContainerPath(matchInner[0])
Expand Down
20 changes: 12 additions & 8 deletions client/src/driver/BitbakeDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class BitbakeDriver {
bitbakeProcessCommand: string | undefined
onBitbakeProcessChange: EventEmitter = new EventEmitter()

loadSettings (settings: any, workspaceFolder: string = '.'): void {
loadSettings (settings: Record<string, unknown>, workspaceFolder: string = '.'): void {
this.bitbakeSettings = loadBitbakeSettings(settings, workspaceFolder)
logger.debug('BitbakeDriver settings updated: ' + JSON.stringify(this.bitbakeSettings))
}
Expand All @@ -40,22 +40,23 @@ export class BitbakeDriver {
})
}

getBuildConfig (property: keyof BitbakeBuildConfigSettings): any {
getBuildConfig (property: keyof BitbakeBuildConfigSettings): string | NodeJS.Dict<string> | undefined {
return getBuildSetting(this.bitbakeSettings, this.activeBuildConfiguration, property)
}

/// Execute a command in the bitbake environment
async spawnBitbakeProcess (command: string): Promise<IPty> {
const { shell, script } = this.prepareCommand(command)
const cwd = this.getBuildConfig('workingDirectory')
const shellEnv = this.getBuildConfig('shellEnv')
await this.waitForBitbakeToFinish()
logger.debug(`Executing Bitbake command with ${shell} in ${cwd}: ${script}`)
const child = pty.spawn(
shell,
['-c', script],
{
cwd,
env: { ...process.env, ...this.getBuildConfig('shellEnv') }
cwd: typeof(cwd) === 'string' ? cwd : undefined,
env: { ...process.env, ...(typeof shellEnv === 'object' ? shellEnv : {}) }
}
)
this.bitbakeProcess = child
Expand All @@ -79,14 +80,16 @@ export class BitbakeDriver {

prepareCommand (command: string): {
shell: string
shellEnv: Record<string, string>
shellEnv: NodeJS.Dict<string>
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 }
}

Expand Down Expand Up @@ -129,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
Expand Down
Loading