Skip to content

Commit bb11cf5

Browse files
build 2 - 1.4.3
1 parent 7d4888c commit bb11cf5

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

dist/src/libraries/Downloader.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function getZipData(entry) {
5151
}
5252
function handleTarExtraction(filepath, extractedPath) {
5353
return new Promise((resolve, reject) => {
54-
(0, child_process_1.exec)(`tar -xf ${filepath} -C ${extractedPath}`, (error, stdout, stderr) => {
54+
(0, child_process_1.execFile)(`tar`, ['-xf', filepath, '-C', extractedPath], (error, stdout, stderr) => {
5555
if (error || stderr) {
5656
return reject(error || stderr);
5757
}
@@ -181,7 +181,6 @@ function downloadBinary(binaryInfo, options, logger) {
181181
const fileExtension = url.slice(lastDashIndex).split('.').splice(1).join('.');
182182
if (options.downloadBinaryOnce) {
183183
const extractedPath = `${dirpath}/${version}`;
184-
await fsPromises.mkdir(extractedPath, { recursive: true });
185184
const binaryPath = (0, path_1.normalize)(`${extractedPath}/mysql/bin/mysqld${process.platform === 'win32' ? '.exe' : ''}`);
186185
const archivePath = `${dirpath}/${version}.${fileExtension}`;
187186
const binaryExists = fs.existsSync(binaryPath);
@@ -191,6 +190,7 @@ function downloadBinary(binaryInfo, options, logger) {
191190
let releaseFunction;
192191
while (true) {
193192
try {
193+
await fsPromises.mkdir(extractedPath, { recursive: true });
194194
releaseFunction = (0, proper_lockfile_1.lockSync)(extractedPath);
195195
break;
196196
}

dist/src/libraries/Executor.js

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
3030
var __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;
3434
Object.defineProperty(exports, "__esModule", { value: true });
3535
const child_process_1 = require("child_process");
3636
const 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);

dist/types/index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ExecException } from "child_process";
1+
import { ExecFileException } from "child_process";
22
export type LOG_LEVEL = 'LOG' | 'WARN' | 'ERROR';
33
export type ServerOptions = {
44
version?: string;
@@ -35,8 +35,8 @@ export type InternalServerOptions = {
3535
export type ExecutorOptions = {
3636
logLevel: LOG_LEVEL;
3737
};
38-
export type ExecuteReturn = {
39-
error: ExecException | null;
38+
export type ExecuteFileReturn = {
39+
error: ExecFileException | null;
4040
stdout: string;
4141
stderr: string;
4242
};

0 commit comments

Comments
 (0)