@@ -75,7 +75,6 @@ if (!platformPackage) {
7575 throw new Error ( `Unsupported target triple: ${ targetTriple } ` ) ;
7676}
7777
78- < << << << HEAD
7978const codexBinaryName = process . platform === "win32" ? "codex.exe" : "codex" ;
8079const localVendorRoot = path . join ( __dirname , ".." , "vendor" ) ;
8180const localBinaryPath = path . join (
@@ -105,27 +104,6 @@ try {
105104}
106105
107106if ( ! vendorRoot ) {
108- === === =
109- function findCodexExecutable ( ) {
110- let vendorRoot ;
111- try {
112- const packageJsonPath = require . resolve ( `${ platformPackage } /package.json` ) ;
113- vendorRoot = path . join ( path . dirname ( packageJsonPath ) , "vendor" ) ;
114- } catch {
115- vendorRoot = path . join ( __dirname , ".." , "vendor" ) ;
116- }
117-
118- const codexExecutable = path . join (
119- vendorRoot ,
120- targetTriple ,
121- "bin" ,
122- process . platform === "win32" ? "codex.exe" : "codex" ,
123- ) ;
124- if ( existsSync ( codexExecutable ) ) {
125- return codexExecutable ;
126- }
127-
128- > >>> >>> rust - v0 .138 .0
129107 const packageManager = detectPackageManager ( ) ;
130108 const updateCommand =
131109 packageManager === "bun"
@@ -136,19 +114,25 @@ function findCodexExecutable() {
136114 ) ;
137115}
138116
139- << < << << HEAD
140117const archRoot = path . join ( vendorRoot , targetTriple ) ;
141118const binaryPath = path . join ( archRoot , "codex" , codexBinaryName ) ;
142- = === ===
143- const binaryPath = findCodexExecutable ( ) ;
144- > >>> >>> rust - v0 .138 .0
145119
146120// Use an asynchronous spawn instead of spawnSync so that Node is able to
147121// respond to signals (e.g. Ctrl-C / SIGINT) while the native binary is
148122// executing. This allows us to forward those signals to the child process
149123// and guarantees that when either the child terminates or the parent
150124// receives a fatal signal, both processes exit in a predictable manner.
151125
126+ function getUpdatedPath ( newDirs ) {
127+ const pathSep = process . platform === "win32" ? ";" : ":" ;
128+ const existingPath = process . env . PATH || "" ;
129+ const updatedPath = [
130+ ...newDirs ,
131+ ...existingPath . split ( pathSep ) . filter ( Boolean ) ,
132+ ] . join ( pathSep ) ;
133+ return updatedPath ;
134+ }
135+
152136/**
153137 * Use heuristics to detect the package manager that was used to install Codex
154138 * in order to give the user a hint about how to update it.
@@ -174,7 +158,6 @@ function detectPackageManager() {
174158 return userAgent ? "npm" : null ;
175159}
176160
177- << < << << HEAD
178161const additionalDirs = [ ] ;
179162const pathDir = path . join ( archRoot , "path" ) ;
180163if ( existsSync ( pathDir ) ) {
@@ -183,17 +166,12 @@ if (existsSync(pathDir)) {
183166const updatedPath = getUpdatedPath ( additionalDirs ) ;
184167
185168const env = { ...process . env , PATH : updatedPath } ;
186- = === ===
187- >>> >>> > rust - v0 .138 .0
188169const packageManagerEnvVar =
189170 detectPackageManager ( ) === "bun"
190171 ? "CODEX_MANAGED_BY_BUN"
191172 : "CODEX_MANAGED_BY_NPM" ;
192- const env = {
193- ...process . env ,
194- [ packageManagerEnvVar ] : "1" ,
195- CODEX_MANAGED_PACKAGE_ROOT : realpathSync ( path . join ( __dirname , ".." ) ) ,
196- } ;
173+ env [ packageManagerEnvVar ] = "1" ;
174+ env . CODEX_MANAGED_PACKAGE_ROOT = realpathSync ( path . join ( __dirname , ".." ) ) ;
197175
198176const child = spawn ( binaryPath , process . argv . slice ( 2 ) , {
199177 stdio : "inherit" ,
0 commit comments