codecane 1.0.403 → 1.0.404

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codecane",
3
- "version": "1.0.403",
3
+ "version": "1.0.404",
4
4
  "description": "AI coding agent",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -232,7 +232,7 @@ async function ensureBinaryExists() {
232
232
  }
233
233
  }
234
234
 
235
- async function checkForUpdates(runningProcess) {
235
+ async function checkForUpdates(runningProcess, exitListener) {
236
236
  try {
237
237
  const currentVersion = getCurrentVersion()
238
238
  if (!currentVersion) return
@@ -240,14 +240,29 @@ async function checkForUpdates(runningProcess) {
240
240
  const latestVersion = await getLatestVersion()
241
241
  if (!latestVersion) return
242
242
 
243
+ console.log(`Current version: ${currentVersion}`)
244
+ console.log(`Latest version: ${latestVersion}`)
245
+
243
246
  if (compareVersions(currentVersion, latestVersion) < 0) {
244
- console.log(`Updating...\n`)
247
+ process.stdout.write(`Updating...`)
248
+
249
+ // Remove the specific exit listener to prevent it from interfering with the update
250
+ runningProcess.removeListener('exit', exitListener)
245
251
 
246
252
  // Kill the running process
247
253
  runningProcess.kill('SIGTERM')
248
254
 
249
- // Wait for graceful shutdown
250
- await new Promise((resolve) => setTimeout(resolve, 500))
255
+ // Wait for the process to actually exit
256
+ await new Promise((resolve) => {
257
+ runningProcess.on('exit', resolve)
258
+ // Fallback timeout in case the process doesn't exit gracefully
259
+ setTimeout(() => {
260
+ if (!runningProcess.killed) {
261
+ runningProcess.kill('SIGKILL')
262
+ }
263
+ resolve()
264
+ }, 5000)
265
+ })
251
266
 
252
267
  await downloadBinary(latestVersion)
253
268
 
@@ -276,14 +291,17 @@ async function main() {
276
291
  cwd: process.cwd(),
277
292
  })
278
293
 
294
+ // Store reference to the exit listener so we can remove it during updates
295
+ const exitListener = (code) => {
296
+ process.exit(code || 0)
297
+ }
298
+
299
+ child.on('exit', exitListener)
300
+
279
301
  // Check for updates in background
280
302
  setTimeout(() => {
281
- checkForUpdates(child)
303
+ checkForUpdates(child, exitListener)
282
304
  }, 100)
283
-
284
- child.on('exit', (code) => {
285
- process.exit(code || 0)
286
- })
287
305
  }
288
306
 
289
307
  // Run the main function