Packager: Options Cleanup
Reviewed By: matryoshcow Differential Revision: D4235221 fbshipit-source-id: 6930a106ed02bec1d77a790641c3dcad46c779b9
This commit is contained in:
parent
c858420b2d
commit
ebc65cecd6
|
@ -8,11 +8,11 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
const child_process = require('child_process');
|
||||
const execFile = require('child_process').execFile;
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const launchChrome = require('../util/launchChrome');
|
||||
const path = require('path');
|
||||
|
||||
const {exec} = require('child_process');
|
||||
|
||||
function launchChromeDevTools(port) {
|
||||
var debuggerURL = 'http://localhost:' + port + '/debugger-ui';
|
||||
|
@ -20,25 +20,25 @@ function launchChromeDevTools(port) {
|
|||
launchChrome(debuggerURL);
|
||||
}
|
||||
|
||||
function escapePath(path) {
|
||||
return '"' + path + '"'; // " Can escape paths with spaces in OS X, Windows, and *nix
|
||||
function escapePath(pathname) {
|
||||
return '"' + pathname + '"'; // " Can escape paths with spaces in OS X, Windows, and *nix
|
||||
}
|
||||
|
||||
function launchDevTools(options, isChromeConnected) {
|
||||
function launchDevTools({port, projectRoots}, isChromeConnected) {
|
||||
// Explicit config always wins
|
||||
var customDebugger = process.env.REACT_DEBUGGER;
|
||||
if (customDebugger) {
|
||||
var projects = options.projectRoots.map(escapePath).join(' ');
|
||||
var projects = projectRoots.map(escapePath).join(' ');
|
||||
var command = customDebugger + ' ' + projects;
|
||||
console.log('Starting custom debugger by executing: ' + command);
|
||||
child_process.exec(command, function (error, stdout, stderr) {
|
||||
exec(command, function (error, stdout, stderr) {
|
||||
if (error !== null) {
|
||||
console.log('Error while starting custom debugger: ' + error);
|
||||
}
|
||||
});
|
||||
} else if (!isChromeConnected()) {
|
||||
// Dev tools are not yet open; we need to open a session
|
||||
launchChromeDevTools(options.port);
|
||||
launchChromeDevTools(port);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
|
||||
const launchEditor = require('../util/launchEditor');
|
||||
|
||||
module.exports = function(args) {
|
||||
module.exports = function({projectRoots}) {
|
||||
return function(req, res, next) {
|
||||
if (req.url === '/open-stack-frame') {
|
||||
var frame = JSON.parse(req.rawBody);
|
||||
launchEditor(frame.file, frame.lineNumber, args['projectRoots']);
|
||||
const frame = JSON.parse(req.rawBody);
|
||||
launchEditor(frame.file, frame.lineNumber, projectRoots);
|
||||
res.end('OK');
|
||||
} else {
|
||||
next();
|
||||
|
|
Loading…
Reference in New Issue