Skip to content

Commit

Permalink
Bring back lost customDebugger function (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslan-bikkinin authored and thymikee committed Mar 15, 2019
1 parent f465789 commit 672ea90
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,41 @@
*/
import launchChrome from '../launchChrome';
import logger from '../../../tools/logger';
import {exec} from 'child_process';

function launchChromeDevTools(port, args = '') {
const debuggerURL = `http://localhost:${port}/debugger-ui${args}`;
logger.info('Launching Dev Tools...');
launchChrome(debuggerURL);
}

function escapePath(pathname) {
// " Can escape paths with spaces in OS X, Windows, and *nix
return `"${pathname}"`;
}

function launchDevTools({port, watchFolders}, isChromeConnected) {
// Explicit config always wins
const customDebugger = process.env.REACT_DEBUGGER;
if (customDebugger) {
customDebugger({watchFolders, customDebugger});
startCustomDebugger({watchFolders, customDebugger});
} else if (!isChromeConnected()) {
// Dev tools are not yet open; we need to open a session
launchChromeDevTools(port);
}
}

function startCustomDebugger({watchFolders, customDebugger}) {
const folders = watchFolders.map(escapePath).join(' ');
const command = `${customDebugger} ${folders}`;
console.log('Starting custom debugger by executing:', command);
exec(command, function(error, stdout, stderr) {
if (error !== null) {
console.log('Error while starting custom debugger:', error);
}
});
}

export default function getDevToolsMiddleware(options, isChromeConnected) {
return function devToolsMiddleware(req, res, next) {
if (req.url === '/launch-safari-devtools') {
Expand Down
7 changes: 1 addition & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5695,15 +5695,10 @@ [email protected]:
version "0.0.8"
resolved "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"

minimist@^1.1.1, minimist@^1.1.3:
minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0:
version "1.2.0"
resolved "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"

minimist@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=

minimist@~0.0.1:
version "0.0.10"
resolved "http://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf"
Expand Down

0 comments on commit 672ea90

Please sign in to comment.