refactor(utils): add support for custom BROWSER environment variable
- Remove hardcoded Windows and Linux Chrome paths from constants. - Update `getChromePath` to check for a `BROWSER` environment variable first. - This allows overriding the default browser executable path at runtime without modifying source code.
This commit is contained in:
parent
83e9307011
commit
65828c5055
@ -15,8 +15,6 @@ export const puppeteerInitArgs = [
|
||||
|
||||
export const CHROME = {
|
||||
Windows: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
|
||||
// Windows: 'C:\\Users\\kyuus\\.cache\\puppeteer\\chrome\\win64-146.0.7680.153\\chrome-win64\\chrome.exe',
|
||||
// Linux: '/usr/bin/google-chrome',
|
||||
Linux: '/usr/bin/chromium',
|
||||
Mac: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
|
||||
};
|
||||
@ -6,6 +6,9 @@ export const redis = new RedisClient(process.env.REDIS);
|
||||
export const getBandaiRawCookieRedisKey = (email: string) => `bandai:cookies:${email}:raw`;
|
||||
|
||||
export const getChromePath = () => {
|
||||
if (process.env.BROWSER) {
|
||||
return process.env.BROWSER;
|
||||
}
|
||||
const platform = process.platform;
|
||||
if (platform === 'win32') return CHROME.Windows;
|
||||
if (platform === 'linux') return CHROME.Linux;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user