diff --git a/src/constants.ts b/src/constants.ts index 97c59147..17e7ba37 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ export const isWindows: boolean = /^win/.test(process.platform); +export const isLinux: boolean = /^linux/.test(process.platform); import * as fs from 'fs'; import assert from 'node:assert'; diff --git a/src/extension.ts b/src/extension.ts index 3f769b93..b0f82c2d 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -24,7 +24,6 @@ import { type ITreeItemPickerContext, } from '@microsoft/vscode-azext-utils'; import { AzExtResourceType, getAzureResourcesExtensionApi } from '@microsoft/vscode-azureresources-api'; -import { platform } from 'os'; import * as vscode from 'vscode'; import { findTreeItem } from './commands/api/findTreeItem'; import { pickTreeItem } from './commands/api/pickTreeItem'; @@ -36,6 +35,8 @@ import { cosmosMongoFilter, cosmosTableFilter, doubleClickDebounceDelay, + isLinux, + isWindows, sqlFilter, } from './constants'; import { DatabasesFileSystem } from './DatabasesFileSystem'; @@ -142,10 +143,10 @@ export async function activateInternal( }, ); registerCommandWithTreeNodeUnwrapping('cosmosDB.attachEmulator', async (actionContext: IActionContext) => { - if (platform() !== 'win32') { + if ((!isWindows && !isLinux)) { actionContext.errorHandling.suppressReportIssue = true; throw new Error( - localize('emulatorNotSupported', 'The Cosmos DB emulator is only supported on Windows.'), + localize('emulatorNotSupported', 'The Cosmos DB emulator is only supported on Windows and Linux.'), ); } diff --git a/src/tree/AttachedAccountsTreeItem.ts b/src/tree/AttachedAccountsTreeItem.ts index e815f397..c1bd31de 100644 --- a/src/tree/AttachedAccountsTreeItem.ts +++ b/src/tree/AttachedAccountsTreeItem.ts @@ -16,7 +16,7 @@ import { type MongoClient } from 'mongodb'; import * as vscode from 'vscode'; import { API, getExperienceFromApi, getExperienceQuickPick, getExperienceQuickPicks } from '../AzureDBExperiences'; import { removeTreeItemFromCache } from '../commands/api/apiCache'; -import { emulatorPassword, isWindows } from '../constants'; +import { emulatorPassword, isLinux, isWindows } from '../constants'; import { parseDocDBConnectionString } from '../docdb/docDBConnectionStrings'; import { type CosmosDBCredential } from '../docdb/getCosmosClient'; import { DocDBAccountTreeItem } from '../docdb/tree/DocDBAccountTreeItem'; @@ -47,7 +47,7 @@ export const MONGO_CONNECTION_EXPECTED: string = 'Connection string must start w const localMongoConnectionString: string = 'mongodb://127.0.0.1:27017'; export class AttachedAccountsTreeItem extends AzExtParentTreeItem { - public static contextValue: string = 'cosmosDBAttachedAccounts' + (isWindows ? 'WithEmulator' : 'WithoutEmulator'); + public static contextValue: string = 'cosmosDBAttachedAccounts' + ((isWindows || isLinux) ? 'WithEmulator' : 'WithoutEmulator'); public readonly contextValue: string = AttachedAccountsTreeItem.contextValue; public readonly label: string = 'Attached Database Accounts'; public childTypeLabel: string = 'Account'; @@ -141,7 +141,7 @@ export class AttachedAccountsTreeItem extends AzExtParentTreeItem { commandId: 'cosmosDB.attachEmulator', includeInTreeItemPicker: true, }); - return isWindows ? [attachDatabaseAccount, attachEmulator] : [attachDatabaseAccount]; + return (isWindows || isLinux) ? [attachDatabaseAccount, attachEmulator] : [attachDatabaseAccount]; } public isAncestorOfImpl(contextValue: string): boolean {