Commit 05e3246a authored by Fred Chasen's avatar Fred Chasen
Browse files

Merge branch 'mr-18-fix' into 'master'

Bring in changes from MR #18: Add a possibility to pass extra arguments to puppeteer

See merge request !20
parents 6b9b338f 27b0d37c
Pipeline #758 passed with stages
in 1 minute and 5 seconds
......@@ -39,6 +39,7 @@ pagedjs-cli ./path/to/index.html -o result.pdf
rendering. This is useful for adding custom pagedjs handlers. The option
can be repeated. (default: [])
--browserEndpoint Use a remote Chrome server with browserWSEndpoint
--browserArgs <browserArgs> Additional comma separated flags for browser
```
## Hyphenation
......
......@@ -8,6 +8,10 @@ const fs = require("fs");
// const writeFileAsync = promisify(fs.writeFile);
const replaceExt = require("replace-ext");
function commaSeparatedList(value) {
return value.split(',');
}
program
.version(require("../package.json").version)
.arguments("[inputPath]")
......@@ -40,6 +44,7 @@ program
"adding custom pagedjs handlers. The option can be repeated.",
collect, [])
.option("--browserEndpoint <browserEndpoint>", "Use a remote Chrome server with browserWSEndpoint")
.option("--browserArgs <browserArgs>", "Launch Chrome with comma separated args", commaSeparatedList)
.parse(process.argv);
function collect(value, previous) {
......@@ -117,6 +122,7 @@ if (typeof input === "string") {
additionalScripts: program.additionalScript,
browserEndpoint: program.browserEndpoint,
timeout: program.timeout,
browserArgs: program.browserArgs
};
if (program.forceTransparentBackground) {
......
......@@ -26,6 +26,7 @@ class Printer extends EventEmitter {
this.allowedDomains = options.allowedDomains || [];
this.ignoreHTTPSErrors = options.ignoreHTTPSErrors;
this.browserWSEndpoint = options.browserEndpoint;
this.browserArgs = options.browserArgs;
this.overrideDefaultBackgroundColor = options.overrideDefaultBackgroundColor;
this.timeout = options.timeout;
......@@ -43,6 +44,10 @@ class Printer extends EventEmitter {
puppeteerOptions.args.push("--allow-file-access-from-files");
}
if (this.browserArgs) {
puppeteerOptions.args.push(...this.browserArgs);
}
if (this.browserWSEndpoint) {
puppeteerOptions.browserWSEndpoint = this.browserWSEndpoint;
this.browser = await puppeteer.connect(puppeteerOptions);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment