Merge pull request #3100 from foghina/run_linux

[cli] spawn xterm on linux to run the packager
This commit is contained in:
Alexander Kotliarskyi 2015-09-29 15:34:02 -07:00
commit b903754116
2 changed files with 17 additions and 7 deletions

View File

@ -31,9 +31,10 @@ function buildAndRun() {
}
try {
var packageName = fs.readFileSync('app/src/main/AndroidManifest.xml', 'utf8').match(/package="(.+?)"/)[1];
var adbPath = process.env.ANDROID_HOME ? process.env.ANDROID_HOME + '/platform-tools/adb' : 'adb';
var adbArgs = ['shell', 'am', 'start', '-n', packageName + '/.MainActivity'];
console.log(chalk.bold('Starting the app (adb ' + adbArgs.join(' ') + ')...'));
child_process.spawnSync('adb', adbArgs, {
console.log(chalk.bold('Starting the app (' + adbPath + ' ' + adbArgs.join(' ') + ')...'));
child_process.spawnSync(adbPath, adbArgs, {
stdio: [process.stdin, process.stdout, process.stderr]
});
} catch (e) {
@ -62,6 +63,8 @@ module.exports = function() {
console.log(chalk.yellow('[warn] JS server not recognized, continuing with build...'));
}
buildAndRun();
// make sure we don't wait around for the packager process
process.exit();
});
});
statusReq.on('error', function() {
@ -70,4 +73,4 @@ module.exports = function() {
runPackager(true);
buildAndRun();
});
};
};

View File

@ -5,9 +5,16 @@ var child_process = require('child_process');
module.exports = function(newWindow) {
if (newWindow) {
child_process.spawnSync('open', [
path.resolve(__dirname, '..', 'packager', 'launchPackager.command')
]);
var launchPackagerScript =
path.resolve(__dirname, '..', 'packager', 'launchPackager.command');
if (process.platform === 'darwin') {
child_process.spawnSync('open', [launchPackagerScript]);
} else if (process.platform === 'linux') {
child_process.spawn(
'xterm',
['-e', 'sh', launchPackagerScript],
{detached: true});
}
} else {
child_process.spawn('sh', [
path.resolve(__dirname, '..', 'packager', 'packager.sh'),
@ -15,4 +22,4 @@ module.exports = function(newWindow) {
process.cwd(),
], {stdio: 'inherit'});
}
};
};