This commit is contained in:
Connor Peet 2021-12-29 15:53:52 -08:00
Родитель e34fb2c02a
Коммит c259111bd6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: CF8FD2EA0DBC61BD
9 изменённых файлов: 3251 добавлений и 1210 удалений

Просмотреть файл

@ -10,7 +10,6 @@ module.exports = {
rules: {
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/interface-name-prefix': ['error', { prefixWithI: 'always' }],
'header/header': [
'error',
'block',

4379
package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -36,20 +36,20 @@
"tabWidth": 2
},
"devDependencies": {
"@types/chai": "^4.2.9",
"@types/mocha": "^7.0.1",
"@types/node": "^13.7.1",
"@types/sinon": "^7.5.1",
"@typescript-eslint/eslint-plugin": "^2.20.0",
"@typescript-eslint/parser": "^2.20.0",
"chai": "^4.2.0",
"eslint": "^6.8.0",
"eslint-plugin-header": "^3.0.0",
"mocha": "^7.0.1",
"prettier": "^1.19.1",
"@types/chai": "^4.3.0",
"@types/mocha": "^9.0.0",
"@types/node": "^17.0.5",
"@types/sinon": "^10.0.6",
"@typescript-eslint/eslint-plugin": "^5.8.1",
"@typescript-eslint/parser": "^5.8.1",
"chai": "^4.3.4",
"eslint": "^8.5.0",
"eslint-plugin-header": "^3.1.1",
"mocha": "^9.1.3",
"prettier": "^2.5.1",
"rimraf": "^3.0.2",
"sinon": "^8.1.1",
"typescript": "^3.9.1-rc"
"sinon": "^12.0.1",
"typescript": "^4.5.4"
},
"dependencies": {
"execa": "^4.0.0"

Просмотреть файл

@ -71,8 +71,7 @@ describe('darwin: chrome', () => {
quality: Quality.Stable,
},
{
path:
'/Users/foo/Applications (Parallels)/{f5861500-b6d1-4929-b85d-d920e2656184} Applications.localized/Google Chrome.app/Contents/MacOS/Google Chrome',
path: '/Users/foo/Applications (Parallels)/{f5861500-b6d1-4929-b85d-d920e2656184} Applications.localized/Google Chrome.app/Contents/MacOS/Google Chrome',
quality: Quality.Dev,
},
]);
@ -91,7 +90,7 @@ describe('darwin: chrome', () => {
let calls = 0;
expect(
await s.findWhere(exe => {
await s.findWhere((exe) => {
calls++;
return exe.quality === Quality.Stable;
}),
@ -103,13 +102,12 @@ describe('darwin: chrome', () => {
expect(calls).to.equal(1);
expect(
await s.findWhere(exe => {
await s.findWhere((exe) => {
calls++;
return exe.quality === Quality.Dev;
}),
).to.deep.equal({
path:
'/Users/foo/Applications (Parallels)/{f5861500-b6d1-4929-b85d-d920e2656184} Applications.localized/Google Chrome.app/Contents/MacOS/Google Chrome',
path: '/Users/foo/Applications (Parallels)/{f5861500-b6d1-4929-b85d-d920e2656184} Applications.localized/Google Chrome.app/Contents/MacOS/Google Chrome',
quality: Quality.Dev,
});
});

Просмотреть файл

@ -97,7 +97,7 @@ describe('darwin: edge', () => {
let calls = 0;
expect(
await s.findWhere(exe => {
await s.findWhere((exe) => {
calls++;
return exe.quality === Quality.Stable;
}),
@ -109,7 +109,7 @@ describe('darwin: edge', () => {
expect(calls).to.equal(1);
expect(
await s.findWhere(exe => {
await s.findWhere((exe) => {
calls++;
return exe.quality === Quality.Canary;
}),

Просмотреть файл

@ -17,7 +17,7 @@ describe('DarwinFinderBase', () => {
let accessStub: SinonStub;
beforeEach(() => {
accessStub = stub(fs, 'access').callsFake(path =>
accessStub = stub(fs, 'access').callsFake((path) =>
validPaths.has(path.toString()) ? Promise.resolve() : Promise.reject('no acccess'),
);
});

Просмотреть файл

@ -63,17 +63,15 @@ export abstract class DarwinFinderBase implements IBrowserFinder {
defaultPaths: ReadonlyArray<string>,
suffixes: ReadonlyArray<string>,
) {
const {
stdout,
} = await this.execa.command(
const { stdout } = await this.execa.command(
`${this.lsRegisterCommand} | awk '$0 ~ /${pattern}${pathSuffixRe.source}?$/ { $1=""; print $0 }'`,
{ shell: true, stdio: 'pipe' },
);
const paths = [
...defaultPaths,
...stdout.split('\n').map(l => l.trim().replace(pathSuffixRe, '')),
].filter(l => !!l);
...stdout.split('\n').map((l) => l.trim().replace(pathSuffixRe, '')),
].filter((l) => !!l);
const preferred = this.getPreferredPath();
if (preferred) {

Просмотреть файл

@ -36,7 +36,7 @@ export class LinuxChromeBrowserFinder implements IBrowserFinder {
'/usr/share/applications/',
'/usr/bin',
];
desktopInstallationFolders.forEach(folder => {
desktopInstallationFolders.forEach((folder) => {
for (const bin in this.findChromeExecutables(folder)) {
installations.add(bin);
}
@ -52,7 +52,7 @@ export class LinuxChromeBrowserFinder implements IBrowserFinder {
];
await Promise.all(
executables.map(async executable => {
executables.map(async (executable) => {
try {
const chromePath = execFileSync('which', [executable], { stdio: 'pipe' })
.toString()
@ -93,12 +93,12 @@ export class LinuxChromeBrowserFinder implements IBrowserFinder {
return sort(installations, priorities);
}
private findChromeExecutables(folder: string) {
private async findChromeExecutables(folder: string) {
const argumentsRegex = /(^[^ ]+).*/; // Take everything up to the first space
const chromeExecRegex = '^Exec=/.*/(google-chrome|chrome|chromium)-.*';
const installations: string[] = [];
if (canAccess(this.fs, folder)) {
if (await canAccess(this.fs, folder)) {
// Output of the grep & print looks like:
// /opt/google/chrome/google-chrome --profile-directory
// /home/user/Downloads/chrome-linux/chrome-wrapper %U
@ -115,8 +115,15 @@ export class LinuxChromeBrowserFinder implements IBrowserFinder {
const execPaths = execResult
.toString()
.split(newLineRegex)
.map(execPath => execPath.replace(argumentsRegex, '$1'));
execPaths.forEach(execPath => canAccess(this.fs, execPath) && installations.push(execPath));
.map((execPath) => execPath.replace(argumentsRegex, '$1'));
await Promise.all(
execPaths.map(async (execPath) => {
if (await canAccess(this.fs, execPath)) {
installations.push(execPath);
}
}),
);
}
return installations;

Просмотреть файл

@ -30,7 +30,7 @@ const regexChars = '/\\.?*()^${}|[]+';
export function escapeRegexSpecialChars(str: string, except?: string): string {
const useRegexChars = regexChars
.split('')
.filter(c => !except || except.indexOf(c) < 0)
.filter((c) => !except || except.indexOf(c) < 0)
.join('')
.replace(/[\\\]]/g, '\\$&');
@ -75,9 +75,9 @@ export function sort(installations: Iterable<string>, priorities: IPriority[]):
const defaultPriority = 10;
return (
[...installations]
.filter(inst => !!inst)
.map(inst => {
const priority = priorities.find(p => p.regex.test(inst));
.filter((inst) => !!inst)
.map((inst) => {
const priority = priorities.find((p) => p.regex.test(inst));
return priority
? { path: inst, weight: priority.weight, quality: priority.quality }
: { path: inst, weight: defaultPriority, quality: Quality.Dev };
@ -85,7 +85,7 @@ export function sort(installations: Iterable<string>, priorities: IPriority[]):
// sort based on weight
.sort((a, b) => b.weight - a.weight)
// remove weight
.map(p => ({ path: p.path, quality: p.quality }))
.map((p) => ({ path: p.path, quality: p.quality }))
);
}
@ -108,7 +108,7 @@ export async function findWindowsCandidates(
for (const suffix of suffixes) {
const candidate = win32.join(prefix, suffix.name);
todo.push(
canAccess(fs, candidate).then(ok =>
canAccess(fs, candidate).then((ok) =>
ok ? { path: candidate, quality: suffix.type } : undefined,
),
);