@@ -15,12 +15,24 @@ describe("isolatedCodexLoginCommand", () => {
1515 ) ;
1616 } ) ;
1717
18- it ( "uses a child PowerShell so the current terminal keeps its environment" , ( ) => {
19- expect (
20- isolatedCodexLoginCommand ( "C:\\Tools & Apps\\codex.exe" , "C:\\O'Brien\\home" , "windows" ) ,
21- ) . toBe (
22- "powershell -NoProfile -Command '$env:CODEX_HOME=''C:\\O''''Brien\\home''; $env:CODEX_SQLITE_HOME=''C:\\O''''Brien\\home\\sqlite''; & ''C:\\Tools & Apps\\codex.exe'' login --device-auth'" ,
23- ) ;
18+ it ( "encodes a child PowerShell command for both PowerShell and Command Prompt" , ( ) => {
19+ for ( const [ executablePath , homePath , expectedScript ] of [
20+ [
21+ "C:\\Tools & Apps\\codex.exe" ,
22+ "C:\\O'Brien\\home" ,
23+ "$env:CODEX_HOME='C:\\O''Brien\\home'; $env:CODEX_SQLITE_HOME='C:\\O''Brien\\home\\sqlite'; & 'C:\\Tools & Apps\\codex.exe' login --device-auth" ,
24+ ] ,
25+ [
26+ "C:\\工具\\🚀\\codex.exe" ,
27+ "C:\\用户\\Chai $data (100%)!\\home" ,
28+ "$env:CODEX_HOME='C:\\用户\\Chai $data (100%)!\\home'; $env:CODEX_SQLITE_HOME='C:\\用户\\Chai $data (100%)!\\home\\sqlite'; & 'C:\\工具\\🚀\\codex.exe' login --device-auth" ,
29+ ] ,
30+ ] as const ) {
31+ const command = isolatedCodexLoginCommand ( executablePath , homePath , "windows" ) ;
32+ expect ( command ) . toMatch ( / ^ p o w e r s h e l l - N o P r o f i l e - E n c o d e d C o m m a n d [ A - Z a - z 0 - 9 + / ] + = * $ / ) ;
33+ const payload = command ?. split ( " " ) . at ( - 1 ) ?? "" ;
34+ expect ( Buffer . from ( payload , "base64" ) . toString ( "utf16le" ) ) . toBe ( expectedScript ) ;
35+ }
2436 expect ( isolatedCodexLoginCommand ( "/codex" , "/home" , "unknown" ) ) . toBeNull ( ) ;
2537 } ) ;
2638} ) ;
0 commit comments