UNPKG

526 BJavaScriptView Raw
1const fs = require('fs');
2const altPath = process.argv[2];
3
4let executablePath = getExecutablePath();
5
6if (!executablePath && altPath) {
7 executablePath = getExecutablePath(altPath);
8}
9
10console.log(executablePath);
11
12function 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 // ignore
21 }
22 return null;
23}