electron-html-to
Advanced tools
Comparing version 2.5.1 to 2.5.2
@@ -27,2 +27,6 @@ 'use strict'; | ||
var _mkdirp = require('mkdirp'); | ||
var _mkdirp2 = _interopRequireDefault(_mkdirp); | ||
var _packageJson = require('../package.json'); | ||
@@ -44,3 +48,3 @@ | ||
function writeHtmlFile(opt, tmpPath, type, id, cb) { | ||
function writeHtmlFileIfNeccesary(opt, tmpPath, type, id, cb) { | ||
var htmlPath = undefined; | ||
@@ -60,6 +64,6 @@ | ||
function writeHtml(opt, tmpPath, id, cb) { | ||
function writeHtmlIfNeccesary(opt, tmpPath, id, cb) { | ||
debugConversion('creating temporal html files in %s..', tmpPath); | ||
writeHtmlFile(opt, tmpPath, 'html', id, function (htmlErr) { | ||
writeHtmlFileIfNeccesary(opt, tmpPath, 'html', id, function (htmlErr) { | ||
if (htmlErr) { | ||
@@ -69,3 +73,3 @@ return cb(htmlErr); | ||
writeHtmlFile(opt, tmpPath, 'header', id, function (headerErr) { | ||
writeHtmlFileIfNeccesary(opt, tmpPath, 'header', id, function (headerErr) { | ||
if (headerErr) { | ||
@@ -75,3 +79,3 @@ return cb(headerErr); | ||
writeHtmlFile(opt, tmpPath, 'footer', id, function (footerErr) { | ||
writeHtmlFileIfNeccesary(opt, tmpPath, 'footer', id, function (footerErr) { | ||
if (footerErr) { | ||
@@ -140,34 +144,42 @@ return cb(footerErr); | ||
writeHtml(localOpts, options.tmpDir, id, function (err) { | ||
if (err) { | ||
return cb(err); | ||
_mkdirp2['default'](options.tmpDir, function (mkdirErr) { | ||
if (mkdirErr) { | ||
// eslint-disable-next-line no-param-reassign | ||
mkdirErr.message = 'Error while trying to ensure tmpDir "' + options.tmpDir + '" existence: ' + mkdirErr.message; | ||
return cb(mkdirErr); | ||
} | ||
// prefix the request in order to recognize later in electron protocol handler | ||
localOpts.url = localOpts.url || _url2['default'].format({ | ||
protocol: 'file', | ||
pathname: localOpts.htmlFile | ||
}); | ||
writeHtmlIfNeccesary(localOpts, options.tmpDir, id, function (err) { | ||
if (err) { | ||
return cb(err); | ||
} | ||
localOpts.chromeCommandLineSwitches = options.chromeCommandLineSwitches; | ||
localOpts.extraHeaders = localOpts.extraHeaders || {}; | ||
// prefix the request in order to recognize later in electron protocol handler | ||
localOpts.url = localOpts.url || _url2['default'].format({ | ||
protocol: 'file', | ||
pathname: localOpts.htmlFile | ||
}); | ||
localOpts.output = { | ||
tmpDir: _path2['default'].resolve(_path2['default'].join(options.tmpDir)), | ||
id: id | ||
}; | ||
localOpts.chromeCommandLineSwitches = options.chromeCommandLineSwitches; | ||
localOpts.extraHeaders = localOpts.extraHeaders || {}; | ||
delete localOpts.html; | ||
localOpts.output = { | ||
tmpDir: _path2['default'].resolve(_path2['default'].join(options.tmpDir)), | ||
id: id | ||
}; | ||
debugConversion('starting conversion task [strategy:%s][task id:%s] with options:', options.strategy, id, localOpts); | ||
delete localOpts.html; | ||
if (options.strategy === 'electron-server' || options.strategy === 'electron-ipc') { | ||
return serverIpcStrategyCall(localOpts, converterPath, id, cb); | ||
} | ||
debugConversion('starting conversion task [strategy:%s][task id:%s] with options:', options.strategy, id, localOpts); | ||
if (options.strategy === 'dedicated-process') { | ||
return _dedicatedProcessStrategy2['default'](options, localOpts, converterPath, id, cb); | ||
} | ||
if (options.strategy === 'electron-server' || options.strategy === 'electron-ipc') { | ||
return serverIpcStrategyCall(localOpts, converterPath, id, cb); | ||
} | ||
cb(new Error('Unsupported strategy ' + options.strategy)); | ||
if (options.strategy === 'dedicated-process') { | ||
return _dedicatedProcessStrategy2['default'](options, localOpts, converterPath, id, cb); | ||
} | ||
cb(new Error('Unsupported strategy ' + options.strategy)); | ||
}); | ||
}); | ||
@@ -174,0 +186,0 @@ }; |
@@ -44,3 +44,3 @@ 'use strict'; | ||
// namespace for tmp dir | ||
tmpDir: _path2['default'].join(_os2['default'].tmpDir(), _packageJson.name + '-tmp-data'), | ||
tmpDir: _path2['default'].join(_os2['default'].tmpdir(), _packageJson.name + '-tmp-data'), | ||
strategy: 'electron-ipc' | ||
@@ -47,0 +47,0 @@ }; |
@@ -9,2 +9,3 @@ 'use strict'; | ||
sliced = require('sliced'), | ||
assign = require('object-assign'), | ||
getBrowserWindowOpts = require('./getBrowserWindowOpts'), | ||
@@ -133,3 +134,5 @@ listenRequestsInPage = require('./listenRequestsInPage'), | ||
if (err) { | ||
msg.error = err; | ||
// err.message is lost when serialized, so we need to explicitly set it | ||
msg.error = assign({}, err); | ||
msg.error.message = err.message; | ||
} else { | ||
@@ -136,0 +139,0 @@ msg.response = payload; |
{ | ||
"name": "electron-html-to", | ||
"version": "2.5.1", | ||
"version": "2.5.2", | ||
"description": "Convert html to html/image using electron", | ||
@@ -33,7 +33,7 @@ "main": "lib/index.js", | ||
"debug": "2.2.0", | ||
"electron-workers": "1.10.2", | ||
"electron-workers": "1.10.3", | ||
"lodash.pick": "4.2.1", | ||
"minstache": "1.2.0", | ||
"mkdirp": "0.5.1", | ||
"object-assign": "4.1.0", | ||
"object-assign": "4.1.1", | ||
"pdfjs-dist": "1.5.285", | ||
@@ -40,0 +40,0 @@ "sliced": "1.0.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
81582
1622
+ Addedelectron-workers@1.10.3(transitive)
+ Addedobject-assign@4.1.1(transitive)
- Removedelectron-workers@1.10.2(transitive)
- Removedobject-assign@4.1.0(transitive)
Updatedelectron-workers@1.10.3
Updatedobject-assign@4.1.1