diff --git a/extension/src/extension.ts b/extension/src/extension.ts index 1304efd5fe..3056b1354a 100644 --- a/extension/src/extension.ts +++ b/extension/src/extension.ts @@ -379,6 +379,10 @@ export class Extension extends Disposable implements IExtension { return this.setProjectAvailability() } + public getRoots() { + return this.dvcRoots + } + public async initialize() { this.resetMembers() diff --git a/extension/src/interfaces.ts b/extension/src/interfaces.ts index 3caed58c18..49d6b61978 100644 --- a/extension/src/interfaces.ts +++ b/extension/src/interfaces.ts @@ -3,6 +3,7 @@ export interface IExtension { cwd: string, isCliGlobal?: true ) => Promise + getRoots: () => string[] hasRoots: () => boolean isPythonExtensionUsed: () => Promise diff --git a/extension/src/setup.test.ts b/extension/src/setup.test.ts index 557c2fd816..6612e15109 100644 --- a/extension/src/setup.test.ts +++ b/extension/src/setup.test.ts @@ -65,6 +65,7 @@ const mockedCwd = __dirname const mockedGetCliVersion = jest.fn() const mockedGetFirstWorkspaceFolder = jest.mocked(getFirstWorkspaceFolder) const mockedHasRoots = jest.fn() +const mockedGetRoots = jest.mocked(() => []) const mockedInitialize = jest.fn() const mockedIsPythonExtensionUsed = jest.fn() const mockedResetMembers = jest.fn() @@ -258,6 +259,7 @@ describe('setupWorkspace', () => { describe('setup', () => { const extension = { getCliVersion: mockedGetCliVersion, + getRoots: mockedGetRoots, hasRoots: mockedHasRoots, initialize: mockedInitialize, isPythonExtensionUsed: mockedIsPythonExtensionUsed, diff --git a/extension/src/setup.ts b/extension/src/setup.ts index a1bfb4c507..d2188d678a 100644 --- a/extension/src/setup.ts +++ b/extension/src/setup.ts @@ -161,7 +161,13 @@ export const setup = async (extension: IExtension) => { await extension.setRoots() - const { isAvailable, isCompatible } = await extensionCanRunCli(extension, cwd) + const roots = extension.getRoots() + const dvcRootOrFirstFolder = roots.length > 0 ? roots[0] : cwd + + const { isAvailable, isCompatible } = await extensionCanRunCli( + extension, + dvcRootOrFirstFolder + ) extension.setCliCompatible(isCompatible) extension.setAvailable(isAvailable)