var common = require('../common');
var when = require('when');

function run(argv, options, loader) {
  argv = [
    options.device ? 'run' : 'emulate'
  ];

  if (options._.length) {
    argv.push(options._[0]);
  }

  // TODO(schoon) - What arguments should we pass to the server?
  var npm = common.pFork(common.config().serverRoot, {
    cwd: common.config().serverRoot
  });

  return common.cordova(argv, {
    cwd: common.config().clientRoot
  }).then(function () {
    npm.child.kill();

    return npm;
  });
}

module.exports = run;

var common = require('../common');
var when = require('when');

function run(argv, options, loader) {
  argv = [
    options.device ? 'run' : 'emulate'
  ];

  if (options._.length) {
    argv.push(options._[0]);
  }

  // TODO(schoon) - What arguments should we pass to the server?
  var npm = common.pFork(common.config().serverRoot, {
    cwd: common.config().serverRoot
  });

  return common.cordova(argv, {
    cwd: common.config().clientRoot
  }).then(function () {
    console.log('');
    console.log('Both client and server are now running. Press Ctrl-C to exit.');

    return npm;
  });
}

module.exports = run;

Fix the server exiting too soon.
Fix the server exiting too soon.
