Compare commits

..

9 Commits

Author SHA1 Message Date
0645364ca9 1.0.7 2019-11-15 21:44:13 +01:00
2d3f59cc65 fix(core): update 2019-11-15 21:44:11 +01:00
0e9c81b898 1.0.6 2019-11-15 18:59:29 +01:00
64cd7cd75d fix(core): update 2019-11-15 18:59:29 +01:00
f110320dae 1.0.5 2019-06-03 23:28:44 +02:00
cbc7fcb323 fix(core): update 2019-06-03 23:28:44 +02:00
0dc0e6ad53 1.0.4 2019-06-03 23:18:48 +02:00
a76d7439c4 1.0.3 2019-06-03 22:48:40 +02:00
df0b48cc47 fix(core): update 2019-06-03 22:48:40 +02:00
6 changed files with 555 additions and 455 deletions

921
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartpuppeteer", "name": "@pushrocks/smartpuppeteer",
"version": "1.0.2", "version": "1.0.7",
"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,22 @@
"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": {
"@pushrocks/smartenv": "^4.0.8",
"@types/puppeteer": "^1.20.2",
"puppeteer": "^2.0.0"
},
"files": [ "files": [
"ts/*", "ts/*",
"ts_web/*", "ts_web/*",

View File

@@ -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();

View File

@@ -1,3 +1,9 @@
import * as plugins from './smartpuppeteer.plugins'; // module exports
export * from './smartpuppeteer.classes.smartpuppeteer';
// direct exports
import { puppeteer } from './smartpuppeteer.plugins';
export { puppeteer };
export let standardExport = 'Hi there! :) This is an exported string';

View File

@@ -0,0 +1,39 @@
import * as plugins from './smartpuppeteer.plugins';
export interface IEnvAwareOptions {
forceNoSandbox?: boolean;
}
export const getEnvAwareBrowserInstance = async (
optionsArg: IEnvAwareOptions = {}
): Promise<plugins.puppeteer.Browser> => {
const smartenv = new plugins.smartenv.Smartenv();
const options: IEnvAwareOptions = {
...{
forceNoSandbox: false
},
...optionsArg
};
let chromeArgs: string[] = [];
if ((process.env.CI || options.forceNoSandbox) && !smartenv.isWsl) {
chromeArgs = chromeArgs.concat([
'--no-sandbox',
'--disable-setuid-sandbox'
// '--disable-dev-shm-usage'
]);
}
let headlessBrowser: plugins.puppeteer.Browser;
if (!smartenv.isWsl) {
// lets get the actual instance
headlessBrowser = await plugins.puppeteer.launch({
args: chromeArgs
});
} else {
console.log('Detected WSL. Using chromium.');
headlessBrowser = await plugins.puppeteer.launch({executablePath: '/usr/bin/chromium-browser'});
}
return headlessBrowser;
};

View File

@@ -1,2 +1,13 @@
const removeme = {}; // @pushrocks scope
export { removeme }; import * as smartenv from '@pushrocks/smartenv';
export {
smartenv
};
// third party scope
import puppeteer from 'puppeteer';
export {
puppeteer
}