Setting current working directory for dev server.
Summary: * This allows `react-native` to work for users on fedora. * `react-native run-android` was failing because the launch packager script was unable to find packager.sh (see `source` in `man bash`). * This change sets cwd for the dev server when run with `run-android`. Closes https://github.com/facebook/react-native/pull/7316 Differential Revision: D3255866 fb-gh-sync-id: 88f6b18f7c61636ce8fecef77f7f4e60b1d9a637 fbshipit-source-id: 88f6b18f7c61636ce8fecef77f7f4e60b1d9a637
This commit is contained in:
parent
80fc98cd61
commit
d4cc5b53c7
|
@ -168,32 +168,31 @@ function buildAndRun(args, reject) {
|
|||
}
|
||||
|
||||
function startServerInNewWindow() {
|
||||
var yargV = require('yargs').argv;
|
||||
|
||||
const yargV = require('yargs').argv;
|
||||
const scriptFile = /^win/.test(process.platform) ?
|
||||
'launchPackager.bat' :
|
||||
'launchPackager.command';
|
||||
|
||||
const launchPackagerScript = path.resolve(
|
||||
__dirname, '..', '..', 'packager', scriptFile
|
||||
);
|
||||
const packagerDir = path.resolve(__dirname, '..', '..', 'packager');
|
||||
const launchPackagerScript = path.resolve(packagerDir, scriptFile);
|
||||
const procConfig = {cwd: packagerDir};
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
if (yargV.open) {
|
||||
return child_process.spawnSync('open', ['-a', yargV.open, launchPackagerScript]);
|
||||
return child_process.spawnSync('open', ['-a', yargV.open, launchPackagerScript], procConfig);
|
||||
}
|
||||
return child_process.spawnSync('open', [launchPackagerScript]);
|
||||
return child_process.spawnSync('open', [launchPackagerScript], procConfig);
|
||||
|
||||
} else if (process.platform === 'linux') {
|
||||
procConfig.detached = true;
|
||||
if (yargV.open){
|
||||
return child_process.spawn(yargV.open,['-e', 'sh', launchPackagerScript], {detached: true});
|
||||
return child_process.spawn(yargV.open,['-e', 'sh', launchPackagerScript], procConfig);
|
||||
}
|
||||
return child_process.spawn('sh', [launchPackagerScript],{detached: true});
|
||||
return child_process.spawn('sh', [launchPackagerScript], procConfig);
|
||||
|
||||
} else if (/^win/.test(process.platform)) {
|
||||
return child_process.spawn(
|
||||
'cmd.exe', ['/C', 'start', launchPackagerScript], {detached: true, stdio: 'ignore'}
|
||||
);
|
||||
procConfig.detached = true;
|
||||
procConfig.stdio = 'ignore';
|
||||
return child_process.spawn('cmd.exe', ['/C', 'start', launchPackagerScript], procConfig);
|
||||
} else {
|
||||
console.log(chalk.red(`Cannot start the packager. Unknown platform ${process.platform}`));
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ clear
|
|||
|
||||
THIS_DIR=$(dirname "$0")
|
||||
pushd "$THIS_DIR"
|
||||
source packager.sh
|
||||
source ./packager.sh
|
||||
popd
|
||||
|
||||
echo "Process terminated. Press <enter> to close the window"
|
||||
|
|
Loading…
Reference in New Issue