Skip to content

Commit 1366fb7

Browse files
Merge pull request #36922 from VickyStash/ts-migration/execAsync-test
[No QA] [TS migration] Migrate 'execAsync.js' test to TypeScript
2 parents 57ad70b + 0bc177d commit 1366fb7

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

tests/e2e/utils/execAsync.js renamed to tests/e2e/utils/execAsync.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import {exec} from 'child_process';
2+
import type {ChildProcess} from 'child_process';
23
import * as Logger from './logger';
34

5+
type PromiseWithAbort = Promise<string | void> & {
6+
abort?: () => void;
7+
};
8+
49
/**
510
* Executes a command none-blocking by wrapping it in a promise.
611
* In addition to the promise it returns an abort function.
7-
* @param {string} command
8-
* @param {object} env environment variables
9-
* @returns {Promise<void>}
1012
*/
11-
export default (command, env = {}) => {
12-
let childProcess;
13-
const promise = new Promise((resolve, reject) => {
14-
const finalEnv = {
13+
export default (command: string, env: NodeJS.ProcessEnv = {}): PromiseWithAbort => {
14+
let childProcess: ChildProcess;
15+
const promise: PromiseWithAbort = new Promise<string | void>((resolve, reject) => {
16+
const finalEnv: NodeJS.ProcessEnv = {
1517
...process.env,
1618
...env,
1719
};
@@ -29,7 +31,7 @@ export default (command, env = {}) => {
2931
if (error && error.killed) {
3032
resolve();
3133
} else {
32-
Logger.error(`failed with error: ${error}`);
34+
Logger.error(`failed with error: ${error.message}`);
3335
reject(error);
3436
}
3537
} else {

tests/e2e/utils/logger.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,4 @@ const error = (...args) => {
6666
log(...lines);
6767
};
6868

69-
module.exports = {
70-
log,
71-
info,
72-
warn,
73-
note,
74-
error,
75-
success,
76-
writeToLogFile,
77-
};
69+
export {log, info, warn, note, error, success, writeToLogFile};

0 commit comments

Comments
 (0)