@@ -30,7 +30,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
3030var __importDefault = ( this && this . __importDefault ) || function ( mod ) {
3131 return ( mod && mod . __esModule ) ? mod : { "default" : mod } ;
3232} ;
33- var _Executor_instances , _Executor_execute , _Executor_executeFile , _Executor_killProcess , _Executor_startMySQLProcess , _Executor_setupDataDirectories ;
33+ var _Executor_instances , _Executor_executeFile , _Executor_killProcess , _Executor_startMySQLProcess , _Executor_setupDataDirectories ;
3434Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
3535const child_process_1 = require ( "child_process" ) ;
3636const semver_1 = require ( "semver" ) ;
@@ -83,7 +83,7 @@ class Executor {
8383 const versions = [ ] ;
8484 for ( const dir of servers ) {
8585 const path = `${ process . env . PROGRAMFILES } \\MySQL\\${ dir } \\bin\\mysqld` ;
86- const { error, stdout, stderr } = await __classPrivateFieldGet ( this , _Executor_instances , "m" , _Executor_execute ) . call ( this , `" ${ path } " --version` ) ;
86+ const { error, stdout, stderr } = await __classPrivateFieldGet ( this , _Executor_instances , "m" , _Executor_executeFile ) . call ( this , path , [ ' --version' ] ) ;
8787 if ( error || stderr ) {
8888 return reject ( error || stderr ) ;
8989 }
@@ -110,8 +110,8 @@ class Executor {
110110 }
111111 }
112112 else {
113- const { error, stdout, stderr } = await __classPrivateFieldGet ( this , _Executor_instances , "m" , _Executor_execute ) . call ( this , 'mysqld --version' ) ;
114- if ( stderr && stderr . includes ( 'not found' ) ) {
113+ const { error, stdout, stderr } = await __classPrivateFieldGet ( this , _Executor_instances , "m" , _Executor_executeFile ) . call ( this , 'mysqld' , [ ' --version'] ) ;
114+ if ( error && error . code === 'ENOENT' ) {
115115 resolve ( null ) ;
116116 }
117117 else if ( error || stderr ) {
@@ -161,22 +161,16 @@ class Executor {
161161 } while ( retries <= options . portRetries ) ;
162162 }
163163}
164- _Executor_instances = new WeakSet ( ) , _Executor_execute = function _Executor_execute ( command ) {
164+ _Executor_instances = new WeakSet ( ) , _Executor_executeFile = function _Executor_executeFile ( command , args ) {
165165 return new Promise ( resolve => {
166- ( 0 , child_process_1 . exec ) ( command , { signal : AbortSignal_1 . default . signal } , ( error , stdout , stderr ) => {
166+ ( 0 , child_process_1 . execFile ) ( command , args , { signal : AbortSignal_1 . default . signal } , ( error , stdout , stderr ) => {
167167 resolve ( { error, stdout, stderr } ) ;
168168 } ) ;
169169 } ) ;
170- } , _Executor_executeFile = function _Executor_executeFile ( command , args , cwd ) {
171- return new Promise ( resolve => {
172- ( 0 , child_process_1 . execFile ) ( command , args , { signal : AbortSignal_1 . default . signal , cwd } , ( error , stdout , stderr ) => {
173- resolve ( { stdout, stderr : ( error === null || error === void 0 ? void 0 : error . message ) || stderr } ) ;
174- } ) ;
175- } ) ;
176170} , _Executor_killProcess = async function _Executor_killProcess ( process ) {
177171 let killed = false ;
178172 if ( os . platform ( ) === 'win32' ) {
179- const { error, stderr } = await __classPrivateFieldGet ( this , _Executor_instances , "m" , _Executor_execute ) . call ( this , ` taskkill /pid ${ process . pid } /t /f` ) ;
173+ const { error, stderr } = await __classPrivateFieldGet ( this , _Executor_instances , "m" , _Executor_executeFile ) . call ( this , ' taskkill' , [ ' /pid' , String ( process . pid ) , '/t' , '/f' ] ) ;
180174 if ( ! error && ! stderr ) {
181175 killed = true ;
182176 }
@@ -310,7 +304,7 @@ _Executor_instances = new WeakSet(), _Executor_execute = function _Executor_exec
310304 await fsPromises . mkdir ( datadir , { recursive : true } ) ;
311305 let stderr ;
312306 if ( binaryFilepath === 'mysqld' ) {
313- const { error, stderr : output } = await __classPrivateFieldGet ( this , _Executor_instances , "m" , _Executor_execute ) . call ( this , ` mysqld --no-defaults --datadir=${ datadir } --initialize-insecure` ) ;
307+ const { error, stderr : output } = await __classPrivateFieldGet ( this , _Executor_instances , "m" , _Executor_executeFile ) . call ( this , ' mysqld' , [ ' --no-defaults' , ` --datadir=${ datadir } ` , ' --initialize-insecure' ] ) ;
314308 stderr = output ;
315309 if ( error ) {
316310 this . logger . error ( 'An error occurred while initializing database with system-installed MySQL:' , error ) ;
@@ -320,7 +314,7 @@ _Executor_instances = new WeakSet(), _Executor_execute = function _Executor_exec
320314 else {
321315 let result ;
322316 try {
323- result = await __classPrivateFieldGet ( this , _Executor_instances , "m" , _Executor_executeFile ) . call ( this , `${ binaryFilepath } ` , [ `--no-defaults` , `--datadir=${ datadir } ` , `--initialize-insecure` ] , ( 0 , path_1 . resolve ) ( ` ${ binaryFilepath } /..` ) ) ;
317+ result = await __classPrivateFieldGet ( this , _Executor_instances , "m" , _Executor_executeFile ) . call ( this , `${ binaryFilepath } ` , [ `--no-defaults` , `--datadir=${ datadir } ` , `--initialize-insecure` ] ) ;
324318 }
325319 catch ( e ) {
326320 this . logger . error ( 'Error occurred from executeFile:' , e ) ;
@@ -342,7 +336,7 @@ _Executor_instances = new WeakSet(), _Executor_execute = function _Executor_exec
342336 throw 'Tried to copy libaio into lib folder and MySQL is still failing to initialize. Please check the console for more information.' ;
343337 }
344338 if ( binaryFilepath . slice ( - 16 ) === 'mysql/bin/mysqld' ) {
345- const { error : lderror , stdout, stderr : ldstderr } = await __classPrivateFieldGet ( this , _Executor_instances , "m" , _Executor_execute ) . call ( this , 'ldconfig -p' ) ;
339+ const { error : lderror , stdout, stderr : ldstderr } = await __classPrivateFieldGet ( this , _Executor_instances , "m" , _Executor_executeFile ) . call ( this , 'ldconfig' , [ ' -p'] ) ;
346340 if ( lderror || ldstderr ) {
347341 this . logger . error ( 'The following libaio error occurred:' , stderr ) ;
348342 this . logger . error ( 'After the libaio error, an ldconfig error occurred:' , lderror || ldstderr ) ;
0 commit comments