dashcam 1.3.5-beta → 1.3.7-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.
@@ -13,9 +13,15 @@ import os from 'os';
13
13
 
14
14
  // Get process directory for status files
15
15
  const PROCESS_DIR = path.join(os.homedir(), '.dashcam-cli');
16
+ const PID_FILE = path.join(PROCESS_DIR, 'recording.pid');
16
17
  const STATUS_FILE = path.join(PROCESS_DIR, 'status.json');
17
18
  const RESULT_FILE = path.join(PROCESS_DIR, 'upload-result.json');
18
19
 
20
+ // Ensure process directory exists
21
+ if (!fs.existsSync(PROCESS_DIR)) {
22
+ fs.mkdirSync(PROCESS_DIR, { recursive: true });
23
+ }
24
+
19
25
  // Parse options from command line argument
20
26
  const optionsJson = process.argv[2];
21
27
  if (!optionsJson) {
@@ -33,6 +39,14 @@ logger.info('Background recording process started', {
33
39
  options
34
40
  });
35
41
 
42
+ // Write PID file immediately
43
+ try {
44
+ fs.writeFileSync(PID_FILE, process.pid.toString());
45
+ logger.info('PID file written', { path: PID_FILE, pid: process.pid });
46
+ } catch (error) {
47
+ logger.error('Failed to write PID file', { error });
48
+ }
49
+
36
50
  // Write status file
37
51
  function writeStatus(status) {
38
52
  try {
package/bin/dashcam.js CHANGED
@@ -109,7 +109,7 @@ async function recordingAction(options, command) {
109
109
  }, 2000))
110
110
  ]);
111
111
  if (!hasPermissions) {
112
- log('\n⚠️ Cannot start recording without screen recording permission.');
112
+ log('\nCannot start recording without screen recording permission.');
113
113
  process.exit(1);
114
114
  }
115
115
 
@@ -134,7 +134,7 @@ async function recordingAction(options, command) {
134
134
 
135
135
  const result = await Promise.race([startRecordingPromise, timeoutPromise]);
136
136
 
137
- log(`✅ Recording started successfully (PID: ${result.pid})`);
137
+ log(`Recording started successfully (PID: ${result.pid})`);
138
138
  log(`Output: ${result.outputPath}`);
139
139
  log('');
140
140
  log('Use "dashcam status" to check progress');
@@ -417,7 +417,7 @@ program
417
417
 
418
418
  // Wait for upload to complete (background process handles this)
419
419
  logger.debug('Waiting for background upload to complete...');
420
- console.log('Uploading recording...');
420
+ console.log('Uploading recording...');
421
421
 
422
422
  // Wait up to 2 minutes for upload result to appear
423
423
  const maxWaitForUpload = 120000; // 2 minutes
@@ -434,7 +434,7 @@ program
434
434
  logger.debug('Upload result read attempt', { found: !!uploadResult, shareLink: uploadResult?.shareLink });
435
435
 
436
436
  if (uploadResult && uploadResult.shareLink) {
437
- console.log('📹 Watch your recording:', uploadResult.shareLink);
437
+ console.log('Watch your recording:', uploadResult.shareLink);
438
438
  // Clean up the result file now that we've read it
439
439
  processManager.cleanup();
440
440
  process.exit(0);
@@ -446,7 +446,7 @@ program
446
446
  (!result.snapshotPath || fs.existsSync(result.snapshotPath));
447
447
 
448
448
  if (!filesExist) {
449
- console.log('Recording uploaded by background process');
449
+ console.log('Recording uploaded by background process');
450
450
  logger.info('Files were cleaned up by background process');
451
451
  process.exit(0);
452
452
  }
@@ -466,7 +466,7 @@ program
466
466
  snapshotPath: result.snapshotPath
467
467
  });
468
468
 
469
- console.log('📹 Watch your recording:', uploadResult.shareLink);
469
+ console.log('Watch your recording:', uploadResult.shareLink);
470
470
  } catch (uploadError) {
471
471
  console.error('Upload failed:', uploadError.message);
472
472
  console.log('Recording saved locally:', result.outputPath);
@@ -681,7 +681,7 @@ program
681
681
  project: options.project
682
682
  });
683
683
 
684
- console.log(' Upload complete! Share link:', uploadResult.shareLink);
684
+ console.log('> Upload complete! Share link:', uploadResult.shareLink);
685
685
  process.exit(0);
686
686
 
687
687
  } catch (error) {
@@ -111,16 +111,23 @@ class ProcessManager {
111
111
  }
112
112
 
113
113
  isRecordingActive() {
114
- const pid = this.readPid();
115
114
  const status = this.readStatus();
116
115
 
117
- if (!pid || !this.isProcessRunning(pid)) {
116
+ if (!status || !status.pid) {
118
117
  // Clean up but preserve upload result in case the background process just finished uploading
119
118
  this.cleanup({ preserveResult: true });
120
119
  return false;
121
120
  }
122
121
 
123
- return status && status.isRecording;
122
+ const pid = status.pid;
123
+
124
+ if (!this.isProcessRunning(pid)) {
125
+ // Clean up but preserve upload result in case the background process just finished uploading
126
+ this.cleanup({ preserveResult: true });
127
+ return false;
128
+ }
129
+
130
+ return status.isRecording;
124
131
  }
125
132
 
126
133
  getActiveStatus() {
@@ -149,13 +156,14 @@ class ProcessManager {
149
156
 
150
157
  try {
151
158
  const status = this.readStatus();
152
- const pid = this.readPid();
153
159
 
154
160
  if (!status || !status.isRecording) {
155
161
  logger.warn('No active recording found');
156
162
  return false;
157
163
  }
158
164
 
165
+ const pid = status.pid;
166
+
159
167
  if (!pid || !this.isProcessRunning(pid)) {
160
168
  logger.warn('Background process not running');
161
169
  this.cleanup({ preserveResult: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dashcam",
3
- "version": "1.3.5-beta",
3
+ "version": "1.3.7-beta",
4
4
  "description": "Minimal CLI version of Dashcam desktop app",
5
5
  "main": "bin/dashcam.js",
6
6
  "bin": {