Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0e9c81b898 | |||
| 64cd7cd75d | |||
| f110320dae | |||
| cbc7fcb323 | |||
| 0dc0e6ad53 | |||
| a76d7439c4 | |||
| df0b48cc47 |
899
package-lock.json
generated
899
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
19
package.json
19
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartpuppeteer",
|
"name": "@pushrocks/smartpuppeteer",
|
||||||
"version": "1.0.2",
|
"version": "1.0.6",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "simplified access to puppeteer",
|
"description": "simplified access to puppeteer",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@@ -9,18 +9,21 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/)",
|
||||||
"build": "(tsbuild)",
|
"build": "(tsbuild --web)",
|
||||||
"format": "(gitzone format)"
|
"format": "(gitzone format)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.0.22",
|
"@gitzone/tsbuild": "^2.1.17",
|
||||||
"@gitzone/tstest": "^1.0.15",
|
"@gitzone/tstest": "^1.0.28",
|
||||||
"@pushrocks/tapbundle": "^3.0.7",
|
"@pushrocks/tapbundle": "^3.0.13",
|
||||||
"@types/node": "^10.11.7",
|
"@types/node": "^12.12.7",
|
||||||
"tslint": "^5.11.0",
|
"tslint": "^5.20.1",
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"dependencies": {
|
||||||
|
"@types/puppeteer": "^1.20.2",
|
||||||
|
"puppeteer": "^2.0.0"
|
||||||
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/*",
|
"ts/*",
|
||||||
"ts_web/*",
|
"ts_web/*",
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ import { expect, tap } from '@pushrocks/tapbundle';
|
|||||||
import * as smartpuppeteer from '../ts/index';
|
import * as smartpuppeteer from '../ts/index';
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
tap.test('first test', async () => {
|
||||||
console.log(smartpuppeteer.standardExport);
|
const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({
|
||||||
|
forceNoSandbox: true
|
||||||
|
});
|
||||||
|
await headlessBrowser.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
|||||||
26
ts/index.ts
26
ts/index.ts
@@ -1,3 +1,25 @@
|
|||||||
import * as plugins from './smartpuppeteer.plugins';
|
import puppeteer from 'puppeteer';
|
||||||
|
|
||||||
export let standardExport = 'Hi there! :) This is an exported string';
|
export interface IEnvAwareOptions {
|
||||||
|
forceNoSandbox?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getEnvAwareBrowserInstance = async (optionsArg: IEnvAwareOptions = {}): Promise<puppeteer.Browser> => {
|
||||||
|
const options: IEnvAwareOptions = {
|
||||||
|
...{
|
||||||
|
forceNoSandbox: false
|
||||||
|
},
|
||||||
|
...optionsArg
|
||||||
|
}
|
||||||
|
|
||||||
|
let chromeArgs: string[] = [];
|
||||||
|
if (process.env.CI || options.forceNoSandbox) {
|
||||||
|
chromeArgs = chromeArgs.concat(['--no-sandbox', '--disable-setuid-sandbox']);
|
||||||
|
}
|
||||||
|
const headlessBrowser = await puppeteer.launch({
|
||||||
|
args: chromeArgs
|
||||||
|
});
|
||||||
|
return headlessBrowser;
|
||||||
|
};
|
||||||
|
|
||||||
|
export { puppeteer };
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
const removeme = {};
|
|
||||||
export { removeme };
|
|
||||||
Reference in New Issue
Block a user