1 | const fs = require('fs');
|
2 | const altPath = process.argv[2];
|
3 |
|
4 | let executablePath = getExecutablePath();
|
5 |
|
6 | if (!executablePath && altPath) {
|
7 | executablePath = getExecutablePath(altPath);
|
8 | }
|
9 |
|
10 | console.log(executablePath);
|
11 |
|
12 | function getExecutablePath(dir) {
|
13 | try {
|
14 | const puppeteer = require(dir ? `${dir}/node_modules/puppeteer` : 'puppeteer')
|
15 | const executablePath = puppeteer.executablePath();
|
16 | if (fs.existsSync(executablePath)) {
|
17 | return executablePath;
|
18 | }
|
19 | } catch (err) {
|
20 |
|
21 | }
|
22 | return null;
|
23 | }
|