mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 21:03:05 -07:00
Update user extension enablement logic
This commit is contained in:
@@ -850,7 +850,7 @@ Would you like to attempt to install via "git clone" instead?`,
|
|||||||
|
|
||||||
if (scope !== SettingScope.Session) {
|
if (scope !== SettingScope.Session) {
|
||||||
const scopePath =
|
const scopePath =
|
||||||
scope === SettingScope.Workspace ? this.workspaceDir : homedir();
|
scope === SettingScope.Workspace ? this.workspaceDir : '/';
|
||||||
this.extensionEnablementManager.disable(name, true, scopePath);
|
this.extensionEnablementManager.disable(name, true, scopePath);
|
||||||
}
|
}
|
||||||
await logExtensionDisable(
|
await logExtensionDisable(
|
||||||
@@ -885,7 +885,7 @@ Would you like to attempt to install via "git clone" instead?`,
|
|||||||
|
|
||||||
if (scope !== SettingScope.Session) {
|
if (scope !== SettingScope.Session) {
|
||||||
const scopePath =
|
const scopePath =
|
||||||
scope === SettingScope.Workspace ? this.workspaceDir : homedir();
|
scope === SettingScope.Workspace ? this.workspaceDir : '/';
|
||||||
this.extensionEnablementManager.enable(name, true, scopePath);
|
this.extensionEnablementManager.enable(name, true, scopePath);
|
||||||
}
|
}
|
||||||
await logExtensionEnable(
|
await logExtensionEnable(
|
||||||
|
|||||||
@@ -2032,6 +2032,25 @@ ${INSTALL_WARNING_MESSAGE}`,
|
|||||||
SettingScope.Workspace,
|
SettingScope.Workspace,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should disable an extension globally at the user scope', async () => {
|
||||||
|
createExtension({
|
||||||
|
extensionsDir: userExtensionsDir,
|
||||||
|
name: 'ext1',
|
||||||
|
version: '1.0.0',
|
||||||
|
});
|
||||||
|
await extensionManager.loadExtensions();
|
||||||
|
await extensionManager.disableExtension('ext1', SettingScope.User);
|
||||||
|
|
||||||
|
// Should be disabled in home dir
|
||||||
|
expect(
|
||||||
|
isEnabled({ name: 'ext1', enabledForPath: userExtensionsDir }),
|
||||||
|
).toBe(false);
|
||||||
|
// Should be disabled in some other random path (global)
|
||||||
|
expect(isEnabled({ name: 'ext1', enabledForPath: '/tmp/other' })).toBe(
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('enableExtension', () => {
|
describe('enableExtension', () => {
|
||||||
@@ -2100,6 +2119,29 @@ ${INSTALL_WARNING_MESSAGE}`,
|
|||||||
SettingScope.Workspace,
|
SettingScope.Workspace,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should enable an extension globally at the user scope', async () => {
|
||||||
|
createExtension({
|
||||||
|
extensionsDir: userExtensionsDir,
|
||||||
|
name: 'ext1',
|
||||||
|
version: '1.0.0',
|
||||||
|
});
|
||||||
|
await extensionManager.loadExtensions();
|
||||||
|
|
||||||
|
await extensionManager.disableExtension('ext1', SettingScope.User);
|
||||||
|
expect(isEnabled({ name: 'ext1', enabledForPath: '/tmp/other' })).toBe(
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
|
await extensionManager.enableExtension('ext1', SettingScope.User);
|
||||||
|
|
||||||
|
expect(isEnabled({ name: 'ext1', enabledForPath: '/tmp/other' })).toBe(
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
isEnabled({ name: 'ext1', enabledForPath: userExtensionsDir }),
|
||||||
|
).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user