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:
kyuuseiryuu 2026-03-21 18:23:47 +09:00
parent 83e9307011
commit 65828c5055
2 changed files with 3 additions and 2 deletions

View File

@ -15,8 +15,6 @@ export const puppeteerInitArgs = [
export const CHROME = { export const CHROME = {
Windows: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe', 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', Linux: '/usr/bin/chromium',
Mac: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', Mac: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
}; };

View File

@ -6,6 +6,9 @@ export const redis = new RedisClient(process.env.REDIS);
export const getBandaiRawCookieRedisKey = (email: string) => `bandai:cookies:${email}:raw`; export const getBandaiRawCookieRedisKey = (email: string) => `bandai:cookies:${email}:raw`;
export const getChromePath = () => { export const getChromePath = () => {
if (process.env.BROWSER) {
return process.env.BROWSER;
}
const platform = process.platform; const platform = process.platform;
if (platform === 'win32') return CHROME.Windows; if (platform === 'win32') return CHROME.Windows;
if (platform === 'linux') return CHROME.Linux; if (platform === 'linux') return CHROME.Linux;