Skip to content

Commit

Permalink
Setting current working directory for dev server.
Browse files Browse the repository at this point in the history
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 #7316

Differential Revision: D3255866

fb-gh-sync-id: 88f6b18f7c61636ce8fecef77f7f4e60b1d9a637
fbshipit-source-id: 88f6b18f7c61636ce8fecef77f7f4e60b1d9a637
  • Loading branch information
jsdevel authored and Facebook Github Bot 0 committed May 4, 2016
1 parent 80fc98c commit d4cc5b5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
25 changes: 12 additions & 13 deletions local-cli/runAndroid/runAndroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`));
}
Expand Down
2 changes: 1 addition & 1 deletion packager/launchPackager.command
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit d4cc5b5

Please sign in to comment.