Skip to content

Commit

Permalink
Merge pull request Expensify#36922 from VickyStash/ts-migration/execA…
Browse files Browse the repository at this point in the history
…sync-test

[No QA] [TS migration] Migrate 'execAsync.js' test to TypeScript
  • Loading branch information
neil-marcellini authored Feb 23, 2024
2 parents 57ad70b + 0bc177d commit 1366fb7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
18 changes: 10 additions & 8 deletions tests/e2e/utils/execAsync.js → tests/e2e/utils/execAsync.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import {exec} from 'child_process';
import type {ChildProcess} from 'child_process';
import * as Logger from './logger';

type PromiseWithAbort = Promise<string | void> & {
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<void>}
*/
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<string | void>((resolve, reject) => {
const finalEnv: NodeJS.ProcessEnv = {
...process.env,
...env,
};
Expand All @@ -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 {
Expand Down
10 changes: 1 addition & 9 deletions tests/e2e/utils/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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};

0 comments on commit 1366fb7

Please sign in to comment.