File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 1
1
import { spawnSync } from 'child_process' ;
2
2
import os from 'os' ;
3
3
import path from 'path' ;
4
+ import { chmodSync , statSync } from 'fs' ;
4
5
5
6
const platform = os . platform ( ) ;
6
7
const arch = os . arch ( ) ;
@@ -39,6 +40,14 @@ const executablePath = path.resolve(path.join(
39
40
platform === 'win32' ? 'ipc-json-bridge.exe' : 'ipc-json-bridge'
40
41
) ) ;
41
42
43
+ try {
44
+ const stats = statSync ( executablePath ) ;
45
+ if ( ! ( stats . mode & 0o100 ) ) chmodSync ( executablePath , stats . mode | 0o100 ) ;
46
+ } catch ( error ) {
47
+ console . error ( `Failed to check/fix permissions for ${ executablePath } :` , error . message ) ;
48
+ process . exit ( 1 ) ;
49
+ }
50
+
42
51
const result = spawnSync ( executablePath , process . argv . slice ( 2 ) , { stdio : 'inherit' } ) ;
43
52
44
53
if ( result . error ) {
Original file line number Diff line number Diff line change 1
1
import { spawn , ChildProcess } from 'child_process' ;
2
2
import { join , resolve } from 'path' ;
3
+ import { existsSync , statSync , chmodSync } from 'fs' ;
3
4
import { platform , arch } from 'os' ;
4
5
import { EventEmitter } from 'events' ;
5
6
import {
@@ -34,6 +35,9 @@ export class IpcBridge extends EventEmitter {
34
35
this . socketPath = options . socketPath || '' ;
35
36
if ( this . isClient && ! this . socketPath ) throw new Error ( 'Client mode requires a socket path' ) ;
36
37
this . binaryPath = this . resolveBinaryPath ( options . binaryPath ) ;
38
+ if ( ! existsSync ( this . binaryPath ) ) {
39
+ throw new Error ( `IPC bridge binary not found: ${ this . binaryPath } ` ) ;
40
+ }
37
41
}
38
42
39
43
// Type-safe event emitter methods
@@ -111,6 +115,9 @@ export class IpcBridge extends EventEmitter {
111
115
throw new Error ( 'IPC bridge is already running' ) ;
112
116
}
113
117
118
+ const stats = statSync ( this . binaryPath ) ;
119
+ if ( ! ( stats . mode & 0o100 ) ) chmodSync ( this . binaryPath , stats . mode | 0o100 ) ;
120
+
114
121
return new Promise ( ( resolve , reject ) => {
115
122
const args = [
116
123
this . isClient ? '--client' : '--server' ,
You can’t perform that action at this time.
0 commit comments