Skip to content

Commit a327bb0

Browse files
committed
feat(cli): add --chrome-path option (#700)
1 parent 50989f3 commit a327bb0

File tree

5 files changed

+24
-2
lines changed

5 files changed

+24
-2
lines changed

packages/cli/src/bin/cli.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,4 +384,15 @@ describe('cli', () => {
384384
);
385385
});
386386
});
387+
388+
describe('--chrome-path', () => {
389+
it('should throw error if path does not exist', async () => {
390+
const result = await runCLI(
391+
`file://${SIMPLE_HTML_FILE}`,
392+
'--chrome-path="someinvalidpath"',
393+
'--show-errors'
394+
);
395+
assert.include(result.stderr, 'no chrome binary at');
396+
});
397+
});
387398
});

packages/cli/src/bin/cli.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ program
7777
'--chromedriver-path <path>',
7878
'Absolute path to the desired chromedriver executable'
7979
)
80+
.option(
81+
'--chrome-path <path>',
82+
'Absolute path to the desired chrome executable'
83+
)
8084
.action(cli);
8185

8286
program.parse(process.argv);

packages/cli/src/bin/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ const cli = async (
3636
rules,
3737
disable,
3838
loadDelay,
39-
chromedriverPath
39+
chromedriverPath,
40+
chromePath
4041
} = args;
4142

4243
const showErrors = args.showErrors === true;
@@ -67,7 +68,8 @@ const cli = async (
6768
browser: args.browser,
6869
timeout,
6970
chromeOptions,
70-
chromedriverPath
71+
chromedriverPath,
72+
chromePath
7173
};
7274

7375
args.driver = startDriver(driverConfigs);

packages/cli/src/lib/webdriver.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ const startDriver = async (
2121
}, options);
2222
}
2323

24+
if (config.chromePath) {
25+
options.setChromeBinaryPath(config.chromePath);
26+
}
27+
2428
builder = new Builder()
2529
.forBrowser('chrome')
2630
.setChromeOptions(options)

packages/cli/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface WebdriverConfigParams {
2323
browser: string;
2424
timeout: number;
2525
chromedriverPath?: string;
26+
chromePath?: string;
2627
path?: string;
2728
chromeOptions?: string[];
2829
builder?: Builder;

0 commit comments

Comments
 (0)