fix(core): update

This commit is contained in:
2021-01-08 21:16:25 +00:00
parent 1b72af4702
commit ef55253b8e
10 changed files with 112 additions and 41 deletions

View File

@ -5,9 +5,7 @@ export class IncognitoBrowser {
public status: 'started' | 'stopped' = 'stopped';
public browser: plugins.puppeteer.Browser;
constructor() {
}
constructor() {}
/**
* starts the IncognitoBrowser
@ -15,14 +13,14 @@ export class IncognitoBrowser {
public async start() {
this.status = 'started';
this.browser = await getEnvAwareBrowserInstance();
this.browser.addListener('disconnected', async eventArg => {
this.browser.addListener('disconnected', async (eventArg) => {
try {
this.browser.removeAllListeners();
} catch(err) {}
} catch (err) {}
if (this.status === 'started') {
this.browser = await getEnvAwareBrowserInstance();
}
})
});
}
/**
@ -39,4 +37,4 @@ export class IncognitoBrowser {
throw new Error('you need to start the IncognitoBrowser instance first');
}
}
}
}

View File

@ -10,13 +10,13 @@ export const getEnvAwareBrowserInstance = async (
const smartenv = new plugins.smartenv.Smartenv();
const options: IEnvAwareOptions = {
...{
forceNoSandbox: false
forceNoSandbox: false,
},
...optionsArg
...optionsArg,
};
let chromeArgs: string[] = [];
if ((process.env.CI || options.forceNoSandbox || plugins.os.userInfo().username === 'root')) {
if (process.env.CI || options.forceNoSandbox || plugins.os.userInfo().username === 'root') {
chromeArgs = chromeArgs.concat(['--no-sandbox', '--disable-setuid-sandbox']);
}
@ -24,7 +24,7 @@ export const getEnvAwareBrowserInstance = async (
console.log('launching puppeteer bundled chrome with arguments:');
console.log(chromeArgs);
headlessBrowser = await plugins.puppeteer.launch({
args: chromeArgs
args: chromeArgs,
});
return headlessBrowser;

View File

@ -1,9 +1,7 @@
// node native scope
import * as os from 'os';
export {
os
};
export { os };
// @pushrocks scope
import * as smartdelay from '@pushrocks/smartdelay';