Skip to content

Commit d4cc5b5

Browse files
jsdevelFacebook Github Bot 0
authored andcommitted
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 facebook#7316 Differential Revision: D3255866 fb-gh-sync-id: 88f6b18f7c61636ce8fecef77f7f4e60b1d9a637 fbshipit-source-id: 88f6b18f7c61636ce8fecef77f7f4e60b1d9a637
1 parent 80fc98c commit d4cc5b5

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

local-cli/runAndroid/runAndroid.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -168,32 +168,31 @@ function buildAndRun(args, reject) {
168168
}
169169

170170
function startServerInNewWindow() {
171-
var yargV = require('yargs').argv;
172-
171+
const yargV = require('yargs').argv;
173172
const scriptFile = /^win/.test(process.platform) ?
174173
'launchPackager.bat' :
175174
'launchPackager.command';
176-
177-
const launchPackagerScript = path.resolve(
178-
__dirname, '..', '..', 'packager', scriptFile
179-
);
175+
const packagerDir = path.resolve(__dirname, '..', '..', 'packager');
176+
const launchPackagerScript = path.resolve(packagerDir, scriptFile);
177+
const procConfig = {cwd: packagerDir};
180178

181179
if (process.platform === 'darwin') {
182180
if (yargV.open) {
183-
return child_process.spawnSync('open', ['-a', yargV.open, launchPackagerScript]);
181+
return child_process.spawnSync('open', ['-a', yargV.open, launchPackagerScript], procConfig);
184182
}
185-
return child_process.spawnSync('open', [launchPackagerScript]);
183+
return child_process.spawnSync('open', [launchPackagerScript], procConfig);
186184

187185
} else if (process.platform === 'linux') {
186+
procConfig.detached = true;
188187
if (yargV.open){
189-
return child_process.spawn(yargV.open,['-e', 'sh', launchPackagerScript], {detached: true});
188+
return child_process.spawn(yargV.open,['-e', 'sh', launchPackagerScript], procConfig);
190189
}
191-
return child_process.spawn('sh', [launchPackagerScript],{detached: true});
190+
return child_process.spawn('sh', [launchPackagerScript], procConfig);
192191

193192
} else if (/^win/.test(process.platform)) {
194-
return child_process.spawn(
195-
'cmd.exe', ['/C', 'start', launchPackagerScript], {detached: true, stdio: 'ignore'}
196-
);
193+
procConfig.detached = true;
194+
procConfig.stdio = 'ignore';
195+
return child_process.spawn('cmd.exe', ['/C', 'start', launchPackagerScript], procConfig);
197196
} else {
198197
console.log(chalk.red(`Cannot start the packager. Unknown platform ${process.platform}`));
199198
}

packager/launchPackager.command

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ clear
1313

1414
THIS_DIR=$(dirname "$0")
1515
pushd "$THIS_DIR"
16-
source packager.sh
16+
source ./packager.sh
1717
popd
1818

1919
echo "Process terminated. Press <enter> to close the window"

0 commit comments

Comments
 (0)