dashcam 1.0.2-beta.1 → 1.0.3-beta

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.
@@ -226,8 +226,15 @@ class ProcessManager {
226
226
  const stdoutLog = path.join(logDir, 'background-stdout.log');
227
227
  const stderrLog = path.join(logDir, 'background-stderr.log');
228
228
 
229
- const stdoutFd = fs.openSync(stdoutLog, 'a');
230
- const stderrFd = fs.openSync(stderrLog, 'a');
229
+ // On Windows, we need to use 'ignore' for all stdio to allow the parent to exit
230
+ // On Unix, we can redirect to log files
231
+ const isWindows = process.platform === 'win32';
232
+ let stdoutFd, stderrFd;
233
+
234
+ if (!isWindows) {
235
+ stdoutFd = fs.openSync(stdoutLog, 'a');
236
+ stderrFd = fs.openSync(stderrLog, 'a');
237
+ }
231
238
 
232
239
  // Spawn a detached process that will handle the recording
233
240
  const backgroundProcess = spawn(process.execPath, [
@@ -235,20 +242,27 @@ class ProcessManager {
235
242
  JSON.stringify(options)
236
243
  ], {
237
244
  detached: true,
238
- stdio: ['ignore', stdoutFd, stderrFd], // Log stdout and stderr
245
+ stdio: isWindows ? 'ignore' : ['ignore', stdoutFd, stderrFd],
246
+ windowsHide: true, // Hide the console window on Windows
239
247
  env: {
240
248
  ...process.env,
241
249
  DASHCAM_BACKGROUND: 'true'
242
250
  }
243
251
  });
244
252
 
245
- // Close the file descriptors in the parent process
246
- fs.closeSync(stdoutFd);
247
- fs.closeSync(stderrFd);
253
+ // Close the file descriptors in the parent process (Unix only)
254
+ if (!isWindows) {
255
+ fs.closeSync(stdoutFd);
256
+ fs.closeSync(stderrFd);
257
+ }
248
258
 
249
259
  // Get the background process PID before unreffing
250
260
  const backgroundPid = backgroundProcess.pid;
251
261
 
262
+ // Write PID file immediately so other commands can find the background process
263
+ // Use the spawned process PID rather than waiting for status file
264
+ this.writePid(backgroundPid);
265
+
252
266
  // Allow the parent process to exit independently
253
267
  backgroundProcess.unref();
254
268
 
@@ -259,12 +273,11 @@ class ProcessManager {
259
273
  const status = this.readStatus();
260
274
 
261
275
  if (!status || !status.isRecording) {
276
+ // Clean up PID file if recording failed to start
277
+ this.cleanup();
262
278
  throw new Error('Background process failed to start recording');
263
279
  }
264
280
 
265
- // Write PID file so other commands can find the background process
266
- this.writePid(status.pid);
267
-
268
281
  logger.info('Background recording process started', {
269
282
  pid: status.pid,
270
283
  outputPath: status.outputPath
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dashcam",
3
- "version": "1.0.2-beta.1",
3
+ "version": "1.0.3-beta",
4
4
  "description": "Minimal CLI version of Dashcam desktop app",
5
5
  "main": "bin/index.js",
6
6
  "bin": {