app/lib/commands/index.js
function _handleCommandResult(result) {
  // if we're running via the cli, we can print human-friendly responses
  // otherwise we return proper JSON
  logger.info('handling command result');
  if (result.result) {
    logger.debug(result.result);
  } else if (result.error) {
    logger.error(result.error);
  }

  if (result.error) {
    if (process.env.MAVENSMATE_CONTEXT !== 'cli') {
      result.reject(result.error);
    } else {
      console.error(JSON.stringify({
        error:result.error.message
      }));
      process.exit(1);
    }
  } else {
    if (_.isString(result.result)) {
      var response = {
        message: result.result
      };
      if (process.env.MAVENSMATE_CONTEXT !== 'cli') {
        result.resolve(response);
      } else {
        console.log(JSON.stringify(response));
        process.exit(0);
      }
    } else {
      if (process.env.MAVENSMATE_CONTEXT !== 'cli') {
        result.resolve(result.result);
      } else {
        console.log(JSON.stringify(result.result));
        process.exit(0);
      }
    }
  }
}
function _handleCommandResult(result) {
  // if we're running via the cli, we can print human-friendly responses
  // otherwise we return proper JSON
  logger.info('handling command result');
  if (result.result) {
    logger.debug(result.result);
  } else if (result.error) {
    logger.error(result.error);
  }

  if (result.error) {
    if (process.env.MAVENSMATE_CONTEXT !== 'cli') {
      result.reject(result.error);
    } else {
      console.error(JSON.stringify({
        error:result.error.message
      }));
      process.exit(1);
    }
  } else {
    if (_.isString(result.result)) {
      var response = {
        message: result.result
      };
      if (process.env.MAVENSMATE_CONTEXT !== 'cli') {
        result.resolve(response);
      } else {
        console.log(JSON.stringify(response));
        process.exit(0);
      }
    } else {
      if (process.env.MAVENSMATE_CONTEXT !== 'cli') {
        result.resolve(result.result);
      } else {
        console.log(JSON.stringify(result.result));
        process.exit(0);
      }
    }
  }
}
function _handleCommandResult ( result ) { // if we're running via the cli, we can print human-friendly responses // otherwise we return proper JSON logger . info ( 'handling command result' ) ; if ( result . result ) { logger . debug ( result . result ) ; } else if ( result . error ) { logger . error ( result . error ) ; } if ( result . error ) { if ( process . env . MAVENSMATE_CONTEXT !== 'cli' ) { result . reject ( result . error ) ; } else { console . error ( JSON . stringify ( { error : result . error . message } ) ) ; process . exit ( 1 ) ; } } else { if ( _ . isString ( result . result ) ) { var response = { message : result . result } ; if ( process . env . MAVENSMATE_CONTEXT !== 'cli' ) { result . resolve ( response ) ; } else { console . log ( JSON . stringify ( response ) ) ; process . exit ( 0 ) ; } } else { if ( process . env . MAVENSMATE_CONTEXT !== 'cli' ) { result . resolve ( result . result ) ; } else { console . log ( JSON . stringify ( result . result ) ) ; process . exit ( 0 ) ; } } } }
Responses to the client that executed the command
@param  {Object|String} res   - response from the command
@param  {Boolean} success - whether the command was successfull (TODO: do we need this?)
@param  {Error} error   - error instance (for failed commands)
@return {String|Object|STDOUT}         - depends on the configuration of the client (more documentation needed here)
Responses to the client that executed the command