1
0
Fork 0

Fix lint errors

pull/1/head
Ambrose Chua 2021-09-30 11:56:57 +08:00
parent 4b14fe7d8a
commit a808724383
8 changed files with 14 additions and 31 deletions

View File

@ -9,7 +9,7 @@ const tests = {
signal: ctrl.signal, signal: ctrl.signal,
}); });
const o = await response.json(); const o = await response.json();
return `Cookie: ${o.headers['Cookie']}`; return `Cookie: ${o.headers.Cookie}`;
} catch (error) { } catch (error) {
return error.toString(); return error.toString();
} }
@ -23,7 +23,7 @@ const tests = {
signal: ctrl.signal, signal: ctrl.signal,
}); });
const o = await response.json(); const o = await response.json();
return `Referer: ${o.headers['Referer']}`; return `Referer: ${o.headers.Referer}`;
} catch (error) { } catch (error) {
return error.toString(); return error.toString();
} }
@ -51,7 +51,7 @@ const tests = {
signal: ctrl.signal, signal: ctrl.signal,
}); });
const o = await response.json(); const o = await response.json();
return `Date: ${o.headers['Date']}`; return `Date: ${o.headers.Date}`;
} catch (error) { } catch (error) {
return error.toString(); return error.toString();
} }
@ -65,7 +65,7 @@ const tests = {
signal: ctrl.signal, signal: ctrl.signal,
}); });
const o = await response.json(); const o = await response.json();
return `Host: ${o.headers['Host']}`; return `Host: ${o.headers.Host}`;
} catch (error) { } catch (error) {
return error.toString(); return error.toString();
} }

View File

@ -46,6 +46,7 @@
"unicorn/prefer-node-protocol": "off" "unicorn/prefer-node-protocol": "off"
}, },
"globals": [ "globals": [
"Deno",
"Request", "Request",
"Response", "Response",
"Headers", "Headers",

View File

@ -42,19 +42,5 @@ export const firefox: BrowserDriver = {
}; };
export const safari: BrowserDriver = { export const safari: BrowserDriver = {
path: '/usr/bin/safaridriver', path: '/usr/bin/safaridriver',
args: (port: number, logLevel = 'warn') => { args: (port: number, _logLevel = 'none') => ['-p', `${port}`],
const logLevelArg = {
trace: 'trace',
debug: 'debug',
info: 'info',
warn: 'warn',
error: 'error',
silent: 'fatal',
}[logLevel];
if (!logLevelArg) {
throw new Error('invalid log level');
}
return ['-p', `${port}`, '-l', `${logLevelArg}`];
},
}; };

View File

@ -1,3 +1,4 @@
import process from 'process';
import path from 'path'; import path from 'path';
import logger from '@wdio/logger'; import logger from '@wdio/logger';
import Table from 'cli-table3'; import Table from 'cli-table3';

View File

@ -6,7 +6,7 @@ import getPort from 'get-port';
import tcpPortUsed from 'tcp-port-used'; import tcpPortUsed from 'tcp-port-used';
import WebDriver from 'webdriver'; import WebDriver from 'webdriver';
import {Platform, Result, BrowserDriver, Context} from './types.js'; import {Platform, Context, Result, BrowserDriver} from './types.js';
async function start( async function start(
driver: BrowserDriver, driver: BrowserDriver,

View File

@ -1,13 +1,10 @@
import {platform} from 'os'; import {platform} from 'os';
import {spawn} from 'child_process'; import {spawn} from 'child_process';
import logger from '@wdio/logger';
import {Platform, Result} from './types.js'; import {Platform, Context, Result} from './types.js';
const log = logger('fetch-compare');
export default class PlatformDeno implements Platform { export default class PlatformDeno implements Platform {
async run(ctx: Record<string, any>, file: string): Promise<Result> { async run(ctx: Context, file: string): Promise<Result> {
const child = spawn( const child = spawn(
platform() === 'win32' ? 'deno.exe' : 'deno', platform() === 'win32' ? 'deno.exe' : 'deno',
['run', '--allow-read', '--allow-net=httpbin.org', 'index-deno.js', file], ['run', '--allow-read', '--allow-net=httpbin.org', 'index-deno.js', file],
@ -23,11 +20,12 @@ export default class PlatformDeno implements Platform {
if (code !== 0) { if (code !== 0) {
reject(code); reject(code);
} }
resolve(stdout); resolve(stdout);
}); });
}); });
child.kill(); child.kill();
return JSON.parse(stdout); return JSON.parse(stdout) as Result;
} }
} }

View File

@ -1,11 +1,10 @@
import process from 'process';
import {fork} from 'child_process'; import {fork} from 'child_process';
import path from 'path'; import path from 'path';
import {Platform, Result} from './types.js'; import {Platform, Context, Result} from './types.js';
export default class PlatformNode implements Platform { export default class PlatformNode implements Platform {
async run(ctx: Record<string, any>, file: string): Promise<Result> { async run(ctx: Context, file: string): Promise<Result> {
const child = fork(path.join(ctx.fixturesPath, 'index-node.js'), [file], { const child = fork(path.join(ctx.fixturesPath, 'index-node.js'), [file], {
cwd: ctx.fixturesPath, cwd: ctx.fixturesPath,
}); });

View File

@ -1,6 +1,4 @@
import process from 'process';
import net from 'net'; import net from 'net';
import path from 'path';
import Koa from 'koa'; import Koa from 'koa';
import files from 'koa-files'; import files from 'koa-files';