mirror of
https://github.com/stablyai/orca.git
synced 2026-09-30 08:03:12 +00:00
* fix(terminal): expand variables in Windows PATH * fix(terminal): preserve expanded Windows PATH at spawn --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
expandWindowsEnvironmentVariables,
|
|
expandWindowsPathEnvironmentVariables
|
|
} from './windows-environment-expansion'
|
|
|
|
describe('expandWindowsEnvironmentVariables', () => {
|
|
it('expands names case-insensitively and preserves unknown variables', () => {
|
|
expect(
|
|
expandWindowsEnvironmentVariables('%localappdata%\\agy\\bin;%MISSING%\\bin', {
|
|
LOCALAPPDATA: 'C:\\Users\\orca\\AppData\\Local'
|
|
})
|
|
).toBe('C:\\Users\\orca\\AppData\\Local\\agy\\bin;%MISSING%\\bin')
|
|
})
|
|
|
|
it('expands variables with empty values', () => {
|
|
expect(expandWindowsEnvironmentVariables('before%EMPTY%after', { EMPTY: '' })).toBe(
|
|
'beforeafter'
|
|
)
|
|
})
|
|
})
|
|
|
|
describe('expandWindowsPathEnvironmentVariables', () => {
|
|
it('expands every Windows PATH casing without changing other variables', () => {
|
|
const env = {
|
|
ORCA_PATH_ROOT: 'C:\\Users\\orca',
|
|
Path: '%ORCA_PATH_ROOT%\\bin',
|
|
PATH: '%orca_path_root%\\tools',
|
|
TEMPLATE: '%ORCA_PATH_ROOT%\\template'
|
|
}
|
|
|
|
expandWindowsPathEnvironmentVariables(env, 'win32')
|
|
|
|
expect(env.Path).toBe('C:\\Users\\orca\\bin')
|
|
expect(env.PATH).toBe('C:\\Users\\orca\\tools')
|
|
expect(env.TEMPLATE).toBe('%ORCA_PATH_ROOT%\\template')
|
|
})
|
|
|
|
it('leaves non-Windows PATH values unchanged', () => {
|
|
const env = { ROOT: '/opt/orca', PATH: '%ROOT%/bin:/usr/bin' }
|
|
|
|
expandWindowsPathEnvironmentVariables(env, 'linux')
|
|
|
|
expect(env.PATH).toBe('%ROOT%/bin:/usr/bin')
|
|
})
|
|
})
|