Skip to content

Commit

Permalink
chore: update dependencies and test targets (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
westy92 authored Dec 3, 2020
1 parent a700ae0 commit beb4136
Show file tree
Hide file tree
Showing 11 changed files with 214 additions and 173 deletions.
6 changes: 2 additions & 4 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ environment:
matrix:
- nodejs_version: "8"
platform: x86
# node 7 is skipped, as appveyor only allows 1 concurrent job
# and we want appveyor finishing ASAP. see #2382
# - nodejs_version: "7"
# platform: x86
# AppVeyor only allows 1 concurrent job and we
# want AppVeyor finishing ASAP. See #2382

build: off

Expand Down
9 changes: 6 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
language: node_js
matrix:
include:
- node_js: "8"
- node_js: "10"
- node_js: "12"
# Currently supported Node.js releases: https://nodejs.org/en/about/releases/
- node_js: 8
- node_js: 10
- node_js: 12
- node_js: lts/* # latest LTS release
- node_js: node # latest stable release
sudo: required
cache:
yarn: true
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ npm install chrome-launcher
chrome.port: number;

// Method to kill Chrome (and cleanup the profile folder)
chrome.kill: () => Promise<{}>;
chrome.kill: () => Promise<void>;

// The process id
chrome.pid: number;
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
"clang-format": "^1.0.50",
"mocha": "^7.1.1",
"sinon": "^9.0.1",
"ts-node": "8.3.0",
"typescript": "3.9.2"
"ts-node": "^8.3.0",
"typescript": "^4.1.2"
},
"dependencies": {
"@types/node": "*",
"escape-string-regexp": "^1.0.5",
"escape-string-regexp": "^2.0.0",
"is-wsl": "^2.2.0",
"lighthouse-logger": "^1.0.0",
"mkdirp": "^0.5.3",
Expand Down
12 changes: 6 additions & 6 deletions src/chrome-finder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
*/
'use strict';

const fs = require('fs');
const path = require('path');
const {homedir} = require('os');
const {execSync, execFileSync} = require('child_process');
const escapeRegExp = require('escape-string-regexp');
import fs = require('fs');
import path = require('path');
import {homedir} from 'os';
import {execSync, execFileSync} from 'child_process';
import escapeRegExp = require('escape-string-regexp');
const log = require('lighthouse-logger');

import {getLocalAppDataPath, ChromePathNotSetError} from './utils';
Expand Down Expand Up @@ -190,7 +190,7 @@ export function win32() {
];
const prefixes = [
process.env.LOCALAPPDATA, process.env.PROGRAMFILES, process.env['PROGRAMFILES(X86)']
].filter(Boolean);
].filter(Boolean) as string[];

const customChromePath = resolveChromePath();
if (customChromePath) {
Expand Down
10 changes: 5 additions & 5 deletions src/chrome-launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface LaunchedChrome {
pid: number;
port: number;
process: ChildProcess;
kill: () => Promise<{}>;
kill: () => Promise<void>;
}

export interface ModuleOverrides {
Expand Down Expand Up @@ -286,7 +286,7 @@ class Launcher {
}

// resolves if ready, rejects otherwise
private isDebuggerReady(): Promise<{}> {
private isDebuggerReady(): Promise<void> {
return new Promise((resolve, reject) => {
const client = net.createConnection(this.port!);
client.once('error', err => {
Expand All @@ -304,7 +304,7 @@ class Launcher {
waitUntilReady() {
const launcher = this;

return new Promise((resolve, reject) => {
return new Promise<void>((resolve, reject) => {
let retries = 0;
let waitStatus = 'Waiting for browser.';

Expand Down Expand Up @@ -339,7 +339,7 @@ class Launcher {
}

kill() {
return new Promise<{}>((resolve, reject) => {
return new Promise<void>((resolve, reject) => {
if (this.chrome) {
this.chrome.on('close', () => {
delete this.chrome;
Expand Down Expand Up @@ -368,7 +368,7 @@ class Launcher {
}

destroyTmp() {
return new Promise(resolve => {
return new Promise<void>(resolve => {
// Only clean up the tmp dir if we created it.
if (this.userDataDir === undefined || this.opts.userDataDir !== undefined) {
return resolve();
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import {join} from 'path';
import {execSync} from 'child_process';
import * as mkdirp from 'mkdirp';
const isWsl = require('is-wsl');
import isWsl = require('is-wsl');

export const enum LaunchErrorCodes {
ERR_LAUNCHER_PATH_NOT_SET = 'ERR_LAUNCHER_PATH_NOT_SET',
Expand Down
2 changes: 1 addition & 1 deletion test/chrome-launcher-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const launchChromeWithOpts = async (opts: Options = {}) => {

const chromeInstance =
new Launcher(opts, {fs: fsMock as any, rimraf: spy() as any, spawn: spawnStub as any});
stub(chromeInstance, 'waitUntilReady').returns(Promise.resolve({}));
stub(chromeInstance, 'waitUntilReady').returns(Promise.resolve());

chromeInstance.prepare();

Expand Down
9 changes: 4 additions & 5 deletions test/random-port-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ import * as assert from 'assert';
import {getRandomPort} from '../src/random-port';

describe('Random port generation', () => {
it('generates a valid random port number', () => {
return getRandomPort().then(port => {
// Verify generated port number is valid integer.
assert.ok(Number.isInteger(port) && port > 0 && port <= 0xFFFF);
});
it('generates a valid random port number', async () => {
const port = await getRandomPort();
// Verify generated port number is valid integer.
assert.ok(Number.isInteger(port) && port > 0 && port <= 0xFFFF);
});
});
6 changes: 3 additions & 3 deletions test/utils-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ describe('WSL path format to Windows', () => {
it('transforms basic path', () => {
const wsl = '/mnt/c/Users/user1/AppData/';
const windows = 'C:\\Users\\user1\\AppData\\';
assert.equal(toWinDirFormat(wsl), windows);
assert.strictEqual(toWinDirFormat(wsl), windows);
});

it('transforms if drive letter is different than c', () => {
const wsl = '/mnt/d/Users/user1/AppData';
const windows = 'D:\\Users\\user1\\AppData';
assert.equal(toWinDirFormat(wsl), windows);
assert.strictEqual(toWinDirFormat(wsl), windows);
});

it('getLocalAppDataPath returns a correct path', () => {
const path = '/mnt/c/Users/user1/.bin:/mnt/c/Users/user1:/mnt/c/Users/user1/AppData/';
const appDataPath = '/mnt/c/Users/user1/AppData/Local';
assert.equal(getLocalAppDataPath(path), appDataPath);
assert.strictEqual(getLocalAppDataPath(path), appDataPath);
});
});
Loading

0 comments on commit beb4136

Please sign in to comment.