mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
fix(settings): use resolved opencode binary and verify installed version
This commit is contained in:
1 parent
aab80f9d65
commit
c976420faa
4 files changed
+94
-82
No files matched your search
@@ -117,7 +117,7 @@ import { promises as fs, accessSync, readdirSync } from 'fs'
|
||||
import { execSync, spawnSync } from 'child_process'
|
||||
import path from 'path'
|
||||
import os from 'os'
|
||||
import { ConfigReloadError } from '../../src/services/opencode-single-server'
|
||||
import { ConfigReloadError, resolveOpenCodeExecutable } from '../../src/services/opencode-single-server'
|
||||
import { forceProcessAttestation, resetProcessIdentityProvider } from '../../src/services/opencode/process-identity'
|
||||
import { encryptSecret } from '../../src/utils/crypto'
|
||||
import { ENV } from '@opencode-manager/shared/config/env'
|
||||
@@ -771,6 +771,24 @@ describe('OpenCodeServerManager - server auth', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('prefers the user-installed OpenCode executable over the bundled executable', () => {
|
||||
const accessSyncMock = accessSync as ReturnType<typeof vi.fn>
|
||||
try {
|
||||
accessSyncMock.mockImplementation((candidate) => {
|
||||
if (candidate === '/test/home/.opencode/bin/opencode' || candidate === '/usr/local/bin/opencode') return
|
||||
throw new Error('ENOENT')
|
||||
})
|
||||
|
||||
expect(resolveOpenCodeExecutable()).toBe('/test/home/.opencode/bin/opencode')
|
||||
} finally {
|
||||
accessSyncMock.mockImplementation(() => {
|
||||
const error = new Error('ENOENT: no such file or directory') as NodeJS.ErrnoException
|
||||
error.code = 'ENOENT'
|
||||
throw error
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
it('stamps the quarantined plugin discovery home into the spawned env when enforced', async () => {
|
||||
sandboxRuntimeServiceMock.SandboxRuntimeService.mockImplementation(() => ({
|
||||
isEnabled: () => true,
|
||||
|
||||
Reference in new issue
Block a user