Skip to content

Commit 78dd2d9

Browse files
authored
rewrite tested_app.js to typescript (DevExpress#5067)
1 parent 1d1000f commit 78dd2d9

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/runner/bootstrapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ export default class Bootstrapper {
325325

326326
const testedApp = new TestedApp();
327327

328-
await testedApp.start(this.appCommand, this.appInitDelay);
328+
await testedApp.start(this.appCommand, this.appInitDelay as number);
329329

330330
return testedApp;
331331
}
Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { exec } from 'child_process';
1+
import { ChildProcess, exec } from 'child_process';
22
import { delimiter as pathDelimiter } from 'path';
33
import kill from 'tree-kill';
44
import OS from 'os-family';
@@ -26,13 +26,17 @@ const ENV_PATH_KEY = (function () {
2626

2727

2828
export default class TestedApp {
29-
constructor () {
30-
this.process = null;
29+
private _killed: boolean;
30+
public errorPromise: null | Promise<void>;
31+
private _process: null | ChildProcess;
32+
33+
public constructor () {
34+
this._process = null;
3135
this.errorPromise = null;
32-
this.killed = false;
36+
this._killed = false;
3337
}
3438

35-
async start (command, initDelay) {
39+
public async start (command: string, initDelay: number): Promise<void> {
3640
this.errorPromise = new Promise((resolve, reject) => {
3741
const env = Object.assign({}, process.env);
3842
const path = env[ENV_PATH_KEY] || '';
@@ -42,8 +46,8 @@ export default class TestedApp {
4246

4347
env[ENV_PATH_KEY] = pathParts.join(pathDelimiter);
4448

45-
this.process = exec(command, { env }, err => {
46-
if (!this.killed && err) {
49+
this._process = exec(command, { env }, err => {
50+
if (!this._killed && err) {
4751
const message = err.stack || String(err);
4852

4953
reject(new GeneralError(RUNTIME_ERRORS.testedAppFailedWithError, message));
@@ -57,10 +61,10 @@ export default class TestedApp {
5761
]);
5862
}
5963

60-
async kill () {
61-
this.killed = true;
64+
public async kill (): Promise<void> {
65+
this._killed = true;
6266

63-
const killPromise = new Promise(resolve => kill(this.process.pid, 'SIGTERM', resolve));
67+
const killPromise = new Promise(resolve => kill((this._process as ChildProcess).pid, 'SIGTERM', resolve));
6468

6569
await killPromise;
6670
}

0 commit comments

Comments
 (0)