Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 608104b

Browse files
committed
chore(typescript): converting task files to typescript
1 parent 6d4f98d commit 608104b

10 files changed

+385
-374
lines changed

lib/configParser.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ try {
1919
export interface Config {
2020
specs: Array<string>;
2121
multiCapabilities: Array<any>;
22+
capabilities?: any;
2223
rootElement: string;
2324
allScriptsTimeout: number;
2425
getPageTimeout: number;
@@ -35,6 +36,8 @@ export interface Config {
3536
suite?: string;
3637
suites?: any;
3738
troubleshoot?: boolean;
39+
exclude?: Array<string>| string;
40+
maxSessions?: number;
3841
}
3942

4043
export default class ConfigParser {

lib/launcher.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
'use strict';
66

77
var ConfigParser = require('./configParser').default,
8-
TaskScheduler = require('./taskScheduler'),
8+
TaskScheduler = require('./taskScheduler').default,
99
helper = require('./util'),
1010
log = require('./logger'),
1111
q = require('q'),
12-
TaskRunner = require('./taskRunner');
12+
TaskRunner = require('./taskRunner').default;
1313

1414
var logPrefix = '[launcher]';
1515
var RUNNERS_FAILED_EXIT_CODE = 100;

lib/taskLogger.js

Lines changed: 0 additions & 88 deletions
This file was deleted.

lib/taskLogger.ts

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import {EOL} from 'os';
2+
import * as Logger from './logger';
3+
4+
export default class TaskLogger {
5+
private buffer: string = '';
6+
private insertTag: boolean = true;
7+
8+
/**
9+
* Log output such that metadata are appended.
10+
* Calling log(data) will not flush to console until you call flush()
11+
*
12+
* @constructor
13+
* @param {object} task Task that is being reported.
14+
* @param {number} pid PID of process running the task.
15+
*/
16+
constructor(private task: any, private pid: number) { this.logHeader_(); }
17+
18+
/**
19+
* Log the header for the current task including information such as
20+
* PID, browser name/version, task Id, specs being run.
21+
*
22+
* @private
23+
*/
24+
private logHeader_(): void {
25+
let output = 'PID: ' + this.pid + EOL;
26+
if (this.task.specs.length === 1) {
27+
output += 'Specs: ' + this.task.specs.toString() + EOL + EOL;
28+
}
29+
this.log(output);
30+
}
31+
32+
/**
33+
* Flushes the buffer to stdout.
34+
*/
35+
public flush(): void {
36+
if (this.buffer) {
37+
// Flush buffer if nonempty
38+
Logger.print(EOL + '------------------------------------' + EOL);
39+
Logger.print(this.buffer);
40+
Logger.print(EOL);
41+
this.buffer = '';
42+
}
43+
}
44+
45+
/**
46+
* Log the data in the argument such that metadata are appended.
47+
* The data will be saved to a buffer until flush() is called.
48+
*
49+
* @param {string} data
50+
*/
51+
public log(data: string): void {
52+
var tag = '[';
53+
var capabilities = this.task.capabilities;
54+
tag += (capabilities.logName) ?
55+
capabilities.logName :
56+
(capabilities.browserName) ? capabilities.browserName : '';
57+
tag += (capabilities.version) ? (' ' + capabilities.version) : '';
58+
tag += (capabilities.platform) ? (' ' + capabilities.platform) : '';
59+
tag += (capabilities.logName && capabilities.count < 2) ? '' : ' #' +
60+
this.task.taskId;
61+
tag += '] ';
62+
63+
data = data.toString();
64+
for (var i = 0; i < data.length; i++) {
65+
if (this.insertTag) {
66+
this.insertTag = false;
67+
// This ensures that the '\x1B[0m' appears before the tag, so that
68+
// data remains correct when color is not processed.
69+
// See https://github.com/angular/protractor/pull/1216
70+
if (data[i] === '\x1B' && data.substring(i, i + 4) === '\x1B[0m') {
71+
this.buffer += ('\x1B[0m' + tag);
72+
i += 3;
73+
continue;
74+
}
75+
76+
this.buffer += tag;
77+
}
78+
if (data[i] === '\n') {
79+
this.insertTag = true;
80+
}
81+
this.buffer += data[i];
82+
}
83+
}
84+
}

lib/taskRunner.js

Lines changed: 0 additions & 129 deletions
This file was deleted.

0 commit comments

Comments
 (0)