Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies and test targets #221

Merged
merged 8 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
westy92 marked this conversation as resolved.
Show resolved Hide resolved
- 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
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",
westy92 marked this conversation as resolved.
Show resolved Hide resolved
"escape-string-regexp": "^2.0.0",
"is-wsl": "^2.2.0",
"lighthouse-logger": "^1.0.0",
"mkdirp": "^0.5.3",
westy92 marked this conversation as resolved.
Show resolved Hide resolved
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
14 changes: 7 additions & 7 deletions src/chrome-launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ class Launcher {
});
client.once('connect', () => {
this.cleanup(client);
resolve();
resolve({});
});
});
}
Expand All @@ -304,7 +304,7 @@ class Launcher {
waitUntilReady() {
const launcher = this;

return new Promise((resolve, reject) => {
return new Promise<{}>((resolve, reject) => {
westy92 marked this conversation as resolved.
Show resolved Hide resolved
let retries = 0;
let waitStatus = 'Waiting for browser.';

Expand All @@ -319,7 +319,7 @@ class Launcher {
launcher.isDebuggerReady()
.then(() => {
log.log('ChromeLauncher', waitStatus + `${log.greenify(log.tick)}`);
resolve();
resolve({});
})
.catch(err => {
if (retries > launcher.maxConnectionRetries) {
Expand Down Expand Up @@ -362,16 +362,16 @@ class Launcher {
}
} else {
// fail silently as we did not start chrome
resolve();
resolve({});
}
});
}

destroyTmp() {
return new Promise(resolve => {
return new Promise<{}>(resolve => {
// Only clean up the tmp dir if we created it.
if (this.userDataDir === undefined || this.opts.userDataDir !== undefined) {
return resolve();
return resolve({});
}

if (this.outFile) {
Expand All @@ -384,7 +384,7 @@ class Launcher {
delete this.errFile;
}

this.rimraf(this.userDataDir, () => resolve());
this.rimraf(this.userDataDir, () => 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
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