From 07356afe66b744814a74fe3a786a82d31a00e1a5 Mon Sep 17 00:00:00 2001 From: VickyStash Date: Tue, 20 Feb 2024 17:29:37 +0100 Subject: [PATCH 1/2] [TS migration] Migrate 'execAsync.js' test --- tests/e2e/utils/{execAsync.js => execAsync.ts} | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) rename tests/e2e/utils/{execAsync.js => execAsync.ts} (72%) diff --git a/tests/e2e/utils/execAsync.js b/tests/e2e/utils/execAsync.ts similarity index 72% rename from tests/e2e/utils/execAsync.js rename to tests/e2e/utils/execAsync.ts index 9abc41105f7e..b6beef01b4bb 100644 --- a/tests/e2e/utils/execAsync.js +++ b/tests/e2e/utils/execAsync.ts @@ -1,17 +1,19 @@ import {exec} from 'child_process'; +import type {ChildProcess} from 'child_process'; import * as Logger from './logger'; +type PromiseWithAbort = Promise & { + abort?: () => void; +}; + /** * Executes a command none-blocking by wrapping it in a promise. * In addition to the promise it returns an abort function. - * @param {string} command - * @param {object} env environment variables - * @returns {Promise} */ -export default (command, env = {}) => { - let childProcess; - const promise = new Promise((resolve, reject) => { - const finalEnv = { +export default (command: string, env: NodeJS.ProcessEnv = {}): PromiseWithAbort => { + let childProcess: ChildProcess; + const promise: PromiseWithAbort = new Promise((resolve, reject) => { + const finalEnv: NodeJS.ProcessEnv = { ...process.env, ...env, }; @@ -29,7 +31,7 @@ export default (command, env = {}) => { if (error && error.killed) { resolve(); } else { - Logger.error(`failed with error: ${error}`); + Logger.error(`failed with error: ${error.message}`); reject(error); } } else { From 0bc177d5c9767173d324c9d6a113eafb476e61fe Mon Sep 17 00:00:00 2001 From: VickyStash Date: Thu, 22 Feb 2024 10:42:27 +0100 Subject: [PATCH 2/2] Replace module.exports with export --- tests/e2e/utils/logger.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/tests/e2e/utils/logger.js b/tests/e2e/utils/logger.js index d0770b7aa8e4..6a39b4c10328 100644 --- a/tests/e2e/utils/logger.js +++ b/tests/e2e/utils/logger.js @@ -66,12 +66,4 @@ const error = (...args) => { log(...lines); }; -module.exports = { - log, - info, - warn, - note, - error, - success, - writeToLogFile, -}; +export {log, info, warn, note, error, success, writeToLogFile};