@@ -5,7 +5,11 @@ import FileSystemIde from "core/util/filesystem";
5
5
import { IMessenger } from "core/util/messenger" ;
6
6
import { ReverseMessageIde } from "core/util/reverseMessageIde" ;
7
7
import fs from "fs" ;
8
- import { ChildProcessWithoutNullStreams , spawn } from "node:child_process" ;
8
+ import {
9
+ ChildProcessWithoutNullStreams ,
10
+ execSync ,
11
+ spawn ,
12
+ } from "node:child_process" ;
9
13
import path from "path" ;
10
14
import {
11
15
CoreBinaryMessenger ,
@@ -59,21 +63,65 @@ describe("Test Suite", () => {
59
63
60
64
beforeAll ( async ( ) => {
61
65
const [ platform , arch ] = autodetectPlatformAndArch ( ) ;
62
- const binaryPath = path . join (
63
- __dirname ,
64
- ".." ,
65
- "bin" ,
66
- `${ platform } -${ arch } ` ,
67
- `continue-binary${ platform === "win32" ? ".exe" : "" } ` ,
68
- ) ;
69
- expect ( fs . existsSync ( binaryPath ) ) . toBe ( true ) ;
66
+ const binaryDir = path . join ( __dirname , ".." , "bin" , `${ platform } -${ arch } ` ) ;
67
+ const exe = platform === "win32" ? ".exe" : "" ;
68
+ const binaryPath = path . join ( binaryDir , `continue-binary${ exe } ` ) ;
69
+ const expectedItems = [
70
+ `continue-binary${ exe } ` ,
71
+ `esbuild${ exe } ` ,
72
+ "index.node" ,
73
+ "package.json" ,
74
+ "build/Release/node_sqlite3.node" ,
75
+ ] ;
76
+ expectedItems . forEach ( ( item ) => {
77
+ expect ( fs . existsSync ( path . join ( binaryDir , item ) ) ) . toBe ( true ) ;
78
+ } ) ;
79
+
80
+ // Set execute permissions and remove quarantine attribute if on macOS
81
+ if ( platform !== "win32" ) {
82
+ try {
83
+ fs . chmodSync ( binaryPath , 0o755 ) ;
84
+ console . log ( "Execute permissions set for the binary" ) ;
85
+
86
+ if ( platform === "darwin" ) {
87
+ const indexNodePath = path . join ( binaryDir , "index.node" ) ;
88
+ const filesToUnquarantine = [ binaryPath , indexNodePath ] ;
89
+
90
+ for ( const file of filesToUnquarantine ) {
91
+ try {
92
+ execSync ( `xattr -d com.apple.quarantine "${ file } "` , {
93
+ stdio : "ignore" ,
94
+ } ) ;
95
+ console . log (
96
+ `Quarantine attribute removed from ${ path . basename ( file ) } ` ,
97
+ ) ;
98
+ } catch ( error ) {
99
+ console . warn (
100
+ `Failed to remove quarantine attribute from ${ path . basename ( file ) } :` ,
101
+ error ,
102
+ ) ;
103
+ }
104
+ }
105
+ }
106
+ } catch ( error ) {
107
+ console . error (
108
+ "Error setting permissions or removing quarantine:" ,
109
+ error ,
110
+ ) ;
111
+ }
112
+ }
70
113
71
114
if ( USE_TCP ) {
72
115
messenger = new CoreBinaryTcpMessenger < ToIdeProtocol , FromIdeProtocol > ( ) ;
73
116
} else {
74
- subprocess = spawn ( binaryPath , {
75
- env : { ...process . env , CONTINUE_GLOBAL_DIR } ,
76
- } ) ;
117
+ try {
118
+ subprocess = spawn ( binaryPath , {
119
+ env : { ...process . env , CONTINUE_GLOBAL_DIR } ,
120
+ } ) ;
121
+ } catch ( error ) {
122
+ console . error ( "Error spawning subprocess:" , error ) ;
123
+ throw error ;
124
+ }
77
125
messenger = new CoreBinaryMessenger < ToIdeProtocol , FromIdeProtocol > (
78
126
subprocess ,
79
127
) ;
0 commit comments