Skip to content

Commit

Permalink
feat(convert-svg-core): Add puppeteer.launch options available into CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
leblanc-simon authored and neocotic committed Dec 8, 2017
1 parent c1cd433 commit c79be10
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/convert-svg-core/src/CLI.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ const { EOL } = require('os');
const fs = require('fs');
const getStdin = require('get-stdin').buffer;
const glob = require('glob');
const omit = require('lodash.omit');
const path = require('path');
const pick = require('lodash.pick');
const util = require('util');

const Converter = require('./Converter');
Expand Down Expand Up @@ -98,6 +100,11 @@ class CLI {
flags: '--height <value>',
description: `specify height for ${format}`
},
{
flags: '--puppeteer <json>',
description: 'specify a json object for puppeteer.launch options',
transformer: JSON.parse
},
{
flags: '--scale <value>',
description: 'specify scale to apply to dimensions [1]',
Expand Down Expand Up @@ -144,9 +151,10 @@ class CLI {
*/
async parse(args = []) {
const command = this[_command].parse(args);
const converter = new Converter(this[_provider]);
const options = this[_parseOptions]();

const converter = new Converter(this[_provider], pick(options, 'puppeteer'));

try {
if (command.args.length) {
const filePaths = [];
Expand All @@ -161,11 +169,11 @@ class CLI {
filePaths.push(...files);
}

await this[_convertFiles](converter, filePaths, options);
await this[_convertFiles](converter, filePaths, omit(options, 'puppeteer'));
} else {
const input = await getStdin();

await this[_convertInput](converter, input, options,
await this[_convertInput](converter, input, omit(options, 'puppeteer'),
command.filename ? path.resolve(this[_baseDir], command.filename) : null);
}
} finally {
Expand Down Expand Up @@ -219,6 +227,7 @@ class CLI {
background: command.background,
baseUrl: command.baseUrl,
height: command.height,
puppeteer: command.puppeteer,
scale: command.scale,
width: command.width
};
Expand Down
1 change: 1 addition & 0 deletions packages/convert-svg-to-jpeg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ $ npm install --global convert-svg-to-jpeg
--base-url <url> specify base URL to use for all relative URLs in SVG
--filename <filename> specify filename for the JPEG output when processing STDIN
--height <value> specify height for JPEG
--puppeteer <json> specify a json object for puppeteer.launch options
--scale <value> specify scale to apply to dimensions [1]
--width <value> specify width for JPEG
--quality <value> specify quality for JPEG [100]
Expand Down
1 change: 1 addition & 0 deletions packages/convert-svg-to-png/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ $ npm install --global convert-svg-to-png
--base-url <url> specify base URL to use for all relative URLs in SVG
--filename <filename> specify filename for the PNG output when processing STDIN
--height <value> specify height for PNG
--puppeteer <json> specify a json object for puppeteer.launch options
--scale <value> specify scale to apply to dimensions [1]
--width <value> specify width for PNG
-h, --help output usage information
Expand Down

0 comments on commit c79be10

Please sign in to comment.