Skip to content

Commit 3f8b9b0

Browse files
committed
Try loading Electron rather than assume installed
1 parent 44726ef commit 3f8b9b0

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

  • lib/node_modules/@stdlib/plot/ctor/lib/view/electron

lib/node_modules/@stdlib/plot/ctor/lib/view/electron/index.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,20 @@
66

77
var debug = require( 'debug' )( 'plot:view:electron:main' );
88
var spawn = require( 'child_process' ).spawn;
9-
var electron = require( 'electron' );
109
var path = require( 'path' );
1110
var toHTML = require( 'vdom-to-html' );
11+
var instanceOf = require( '@stdlib/assert/instance-of' );
1212
var ENV = require( '@stdlib/utils/env' );
1313
var copy = require( '@stdlib/utils/copy' );
1414
var merge = require( '@stdlib/utils/merge' );
1515
var readFileSync = require( '@stdlib/fs/read-file' ).sync;
1616
var httpServer = require( '@stdlib/tools/disposable-http-server' );
17+
var tryRequire = require( '@stdlib/utils/try-require' );
18+
19+
20+
// VARIABLES //
21+
22+
var electron = tryRequire( '@stdlib/electron' );
1723

1824

1925
// MAIN //
@@ -24,13 +30,17 @@ var httpServer = require( '@stdlib/tools/disposable-http-server' );
2430
* @private
2531
* @param {Plot} plot - plot context
2632
* @param {VTree} vtree - virtual tree
33+
* @throws {Error} Electron must be properly installed
2734
*/
2835
function view( plot, vtree ) {
2936
var index;
3037
var html;
3138
var opts;
3239
var css;
3340

41+
if ( instanceOf( electron, Error ) ) {
42+
throw new Error( 'invalid operation. Unable to load Electron. Ensure Electron is installed and try again.' );
43+
}
3444
debug( 'Transforming virtual DOM tree to HTML...' );
3545
html = toHTML( vtree );
3646

0 commit comments

Comments
 (0)