|
|
@@ -135,6 +135,32 @@ describe('config-io', () => {
|
|
|
expect(saved.plugin.length).toBe(2);
|
|
|
});
|
|
|
|
|
|
+ test('addPluginToOpenCodeConfig respects OPENCODE_CONFIG_DIR', async () => {
|
|
|
+ const customConfigDir = join(tmpDir, 'custom-opencode');
|
|
|
+ const defaultConfigDir = join(tmpDir, 'opencode');
|
|
|
+ const customConfigPath = join(customConfigDir, 'opencode.jsonc');
|
|
|
+ const defaultConfigPath = join(defaultConfigDir, 'opencode.json');
|
|
|
+
|
|
|
+ process.env.OPENCODE_CONFIG_DIR = customConfigDir;
|
|
|
+ mkdirSync(customConfigDir, { recursive: true });
|
|
|
+ mkdirSync(defaultConfigDir, { recursive: true });
|
|
|
+ writeFileSync(
|
|
|
+ customConfigPath,
|
|
|
+ JSON.stringify({ plugin: ['other', 'oh-my-opencode-slim@1.0.0'] }),
|
|
|
+ );
|
|
|
+ writeFileSync(defaultConfigPath, JSON.stringify({ plugin: ['default'] }));
|
|
|
+ process.argv[1] = '';
|
|
|
+
|
|
|
+ const result = await addPluginToOpenCodeConfig();
|
|
|
+
|
|
|
+ expect(result.success).toBe(true);
|
|
|
+ expect(result.configPath).toBe(customConfigPath);
|
|
|
+ const customSaved = JSON.parse(readFileSync(customConfigPath, 'utf-8'));
|
|
|
+ const defaultSaved = JSON.parse(readFileSync(defaultConfigPath, 'utf-8'));
|
|
|
+ expect(customSaved.plugin).toEqual(['other', 'oh-my-opencode-slim']);
|
|
|
+ expect(defaultSaved.plugin).toEqual(['default']);
|
|
|
+ });
|
|
|
+
|
|
|
test('addPluginToOpenCodeConfig stores package name for bunx temp paths', async () => {
|
|
|
const configPath = join(tmpDir, 'opencode', 'opencode.json');
|
|
|
const packageRoot = join(
|