Skip to content

Commit 672ea90

Browse files
ruslan-bikkininthymikee
authored andcommitted
Bring back lost customDebugger function (#237)
1 parent f465789 commit 672ea90

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

packages/cli/src/commands/server/middleware/getDevToolsMiddleware.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,41 @@
88
*/
99
import launchChrome from '../launchChrome';
1010
import logger from '../../../tools/logger';
11+
import {exec} from 'child_process';
1112

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

19+
function escapePath(pathname) {
20+
// " Can escape paths with spaces in OS X, Windows, and *nix
21+
return `"${pathname}"`;
22+
}
23+
1824
function launchDevTools({port, watchFolders}, isChromeConnected) {
1925
// Explicit config always wins
2026
const customDebugger = process.env.REACT_DEBUGGER;
2127
if (customDebugger) {
22-
customDebugger({watchFolders, customDebugger});
28+
startCustomDebugger({watchFolders, customDebugger});
2329
} else if (!isChromeConnected()) {
2430
// Dev tools are not yet open; we need to open a session
2531
launchChromeDevTools(port);
2632
}
2733
}
2834

35+
function startCustomDebugger({watchFolders, customDebugger}) {
36+
const folders = watchFolders.map(escapePath).join(' ');
37+
const command = `${customDebugger} ${folders}`;
38+
console.log('Starting custom debugger by executing:', command);
39+
exec(command, function(error, stdout, stderr) {
40+
if (error !== null) {
41+
console.log('Error while starting custom debugger:', error);
42+
}
43+
});
44+
}
45+
2946
export default function getDevToolsMiddleware(options, isChromeConnected) {
3047
return function devToolsMiddleware(req, res, next) {
3148
if (req.url === '/launch-safari-devtools') {

yarn.lock

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5695,15 +5695,10 @@ [email protected]:
56955695
version "0.0.8"
56965696
resolved "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
56975697

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

5702-
minimist@^1.2.0:
5703-
version "1.2.0"
5704-
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
5705-
integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=
5706-
57075702
minimist@~0.0.1:
57085703
version "0.0.10"
57095704
resolved "http://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf"

0 commit comments

Comments
 (0)