redux-devtools/packages/redux-devtools-cli/bin/open.js

35 lines
1.0 KiB
JavaScript
Raw Normal View History

var opn = require('opn');
2019-01-05 18:49:52 +03:00
var path = require('path');
var spawn = require('cross-spawn');
function open(app, options) {
2019-01-05 18:49:52 +03:00
if (app === true || app === 'electron') {
try {
2019-01-10 21:51:14 +03:00
spawn.sync(require('electron'), [path.join(__dirname, '..', 'app')]);
2019-01-05 18:49:52 +03:00
} catch (error) {
2019-01-10 21:51:14 +03:00
/* eslint-disable no-console */
if (error.message === "Cannot find module 'electron'") {
2019-01-05 18:49:52 +03:00
// TODO: Move electron to dev-dependences to make our package installation faster when not needed.
2019-01-10 21:51:14 +03:00
console.log(
' \x1b[1;31m[Warn]\x1b[0m Electron module not installed.\n'
);
2019-01-05 18:49:52 +03:00
/*
We will use "npm" to install Electron via "npm install -D".
Do you want to install 'electron' (yes/no): yes
Installing 'electron' (running 'npm install -D webpack-cli')...
*/
} else {
console.log(error);
}
2019-01-10 21:51:14 +03:00
/* eslint-enable no-console */
2019-01-05 18:49:52 +03:00
}
return;
}
2019-01-10 21:51:14 +03:00
opn(
'http://localhost:' + options.port + '/',
app !== 'browser' ? { app: app } : undefined
);
}
module.exports = open;