forked from percy/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost-install.js
More file actions
20 lines (18 loc) · 823 Bytes
/
Copy pathpost-install.js
File metadata and controls
20 lines (18 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import fs from 'fs';
try {
if (!['false', '0', undefined].includes(process.env.PERCY_POSTINSTALL_BROWSER)) {
// Automatically download and install Chromium if PERCY_POSTINSTALL_BROWSER is set
await import('./dist/install.js').then(install => install.chromium());
} else if (!process.send && fs.existsSync('./src')) {
// In development, fork this script with the development loader and always install
await import('child_process').then(cp => cp.fork('./post-install.js', {
execArgv: ['--no-warnings', '--loader=../../scripts/loader.js'],
env: { PERCY_POSTINSTALL_BROWSER: true }
}));
}
} catch (error) {
const { logger } = await import('@percy/logger');
const log = logger('core:post-install');
log.error('Encountered an error while installing Chromium');
log.error(error);
}