2022-06-22 13:25:44 +00:00
|
|
|
import {createRequire} from 'module';
|
|
|
|
import {dirname} from 'path';
|
|
|
|
import {fileURLToPath} from 'url';
|
2022-05-09 11:17:24 +00:00
|
|
|
|
|
|
|
const require = createRequire(import.meta.url);
|
|
|
|
|
2022-06-27 07:24:23 +00:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-05-09 11:17:24 +00:00
|
|
|
let puppeteerDirname: string;
|
|
|
|
|
|
|
|
try {
|
|
|
|
// In some environments, like esbuild, this will throw an error.
|
|
|
|
// We suppress the error since the bundled binary is not expected
|
|
|
|
// to be used or installed in this case and, therefore, the
|
|
|
|
// root directory does not have to be known.
|
|
|
|
puppeteerDirname = dirname(require.resolve('./compat'));
|
|
|
|
} catch (error) {
|
|
|
|
puppeteerDirname = dirname(fileURLToPath(import.meta.url));
|
|
|
|
}
|
|
|
|
|
2022-06-22 13:25:44 +00:00
|
|
|
export {puppeteerDirname};
|