diff --git a/src/darwinChrome.ts b/src/darwinChrome.ts index 9a317c2..5f41bdd 100644 --- a/src/darwinChrome.ts +++ b/src/darwinChrome.ts @@ -32,17 +32,19 @@ export class DarwinChromeBrowserFinder extends DarwinFinderBase { }, ]; - /** - * @override - */ - public async findAll() { - const suffixes = ['/Contents/MacOS/Google Chrome Canary', '/Contents/MacOS/Google Chrome']; + protected override async findAllInner() { + const suffixes = [ + '/Contents/MacOS/Google Chrome Canary', + '/Contents/MacOS/Google Chrome Beta', + '/Contents/MacOS/Google Chrome Dev', + '/Contents/MacOS/Google Chrome', + ]; const defaultPaths = [ '/Applications/Google Chrome.app', '/Applications/Google Chrome Canary.app', ]; const installations = await this.findLaunchRegisteredApps( - 'google chrome\\( canary\\)\\?.app', + 'google chrome[A-Za-z() ]*.app', defaultPaths, suffixes, ); @@ -60,6 +62,16 @@ export class DarwinChromeBrowserFinder extends DarwinFinderBase { weight: 1, quality: Quality.Canary, }, + { + name: 'Chrome Beta.app', + weight: 2, + quality: Quality.Beta, + }, + { + name: 'Chrome Dev.app', + weight: 3, + quality: Quality.Dev, + }, ]), ); } diff --git a/src/darwinEdge.ts b/src/darwinEdge.ts index ce314ab..07d517a 100644 --- a/src/darwinEdge.ts +++ b/src/darwinEdge.ts @@ -32,10 +32,7 @@ export class DarwinEdgeBrowserFinder extends DarwinFinderBase { }, ]; - /** - * @override - */ - public async findAll() { + protected override async findAllInner() { const suffixes = [ '/Contents/MacOS/Microsoft Edge Canary', '/Contents/MacOS/Microsoft Edge Beta', diff --git a/src/darwinFinderBase.ts b/src/darwinFinderBase.ts index 604b19a..59f2b75 100644 --- a/src/darwinFinderBase.ts +++ b/src/darwinFinderBase.ts @@ -26,6 +26,8 @@ export abstract class DarwinFinderBase implements IBrowserFinder { */ protected wellKnownPaths: ReadonlyArray = []; + private foundAll: Promise | undefined; + constructor( protected readonly env: NodeJS.ProcessEnv, private readonly fs: typeof fsPromises, @@ -48,7 +50,15 @@ export abstract class DarwinFinderBase implements IBrowserFinder { /** * @inheritdoc */ - public abstract findAll(): Promise; + public findAll(): Promise { + this.foundAll ??= this.findAllInner(); + return this.foundAll; + } + + /** + * findAll implementation. Cached. + */ + protected abstract findAllInner(): Promise; /** * Returns the environment-configured custom path, if any. @@ -64,7 +74,9 @@ export abstract class DarwinFinderBase implements IBrowserFinder { suffixes: ReadonlyArray, ) { const { stdout } = await this.execa.command( - `${this.lsRegisterCommand} | awk '$0 ~ /${pattern}${pathSuffixRe.source}?$/ { $1=""; print $0 }'`, + `${this.lsRegisterCommand} | awk 'tolower($0) ~ /${pattern.toLowerCase()}${ + pathSuffixRe.source + }?$/ { $1=""; print $0 }'`, { shell: true, stdio: 'pipe' }, );