lib/runner.js
function run(script, args) {

  var res, result, name;
  try {
    res = this.exec.apply(this, [script].concat(args));
    result = res.result;
    //console.dir(result);
    //console.dir(result instanceof Error);
    if(typeof result === 'function') return;
    if(result === undefined) {
      throw new Error('undefined return value is not allowed');
    }else if(
      result !== null
      && !(result instanceof String)
      && !(result instanceof Error)
      && typeof result === 'object'
      && !Array.isArray(result)) {
      throw new Error('object return value is not allowed');
    }
  }catch(e) {
    name = res && res.name ? res.name : 'user_script';
    result = new StoreError(
      null, 'error running script (call to %s): %s', name, e.message);
  }

  if(typeof result === 'boolean') {
    result = Number(result);
  }

  // TODO: check the return value is not an object!!!
  //
  var err = (result instanceof Error);
  if(err) result = result.message;

  process.send({err: err, data: result, str: (result instanceof String)});
}
function run(script, args) {

  var res, result, name;
  try {
    res = this.exec.apply(this, [script].concat(args));
    result = res.result;
    //console.dir(result);
    //console.dir(result instanceof Error);
    if(typeof result === 'function') return;
    if(result === undefined) {
      throw new Error('undefined return value is not allowed');
    }else if(
      result !== null
      && !(result instanceof String)
      && !(result instanceof Error)
      && typeof result === 'object'
      && !Array.isArray(result)) {
      throw new Error('object return value is not allowed');
    }
  }catch(e) {
    name = res && res.name ? res.name : 'user_script';
    result = new StoreError(
      null, 'error running script (call to %s): %s', name, e.message);
  }

  if(typeof result === 'boolean') {
    result = Number(result);
  }

  // TODO: check the return value is not an object!!!
  //
  var err = (result instanceof Error);
  if(err) result = result.message;

  process.send({err: err, data: result, str: (result instanceof String)});
}
function run ( script , args ) { var res , result , name ; try { res = this . exec . apply ( this , [ script ] . concat ( args ) ) ; result = res . result ; //console.dir(result); //console.dir(result instanceof Error); if ( typeof result === 'function' ) return ; if ( result === undefined ) { throw new Error ( 'undefined return value is not allowed' ) ; } else if ( result !== null && ! ( result instanceof String ) && ! ( result instanceof Error ) && typeof result === 'object' && ! Array . isArray ( result ) ) { throw new Error ( 'object return value is not allowed' ) ; } } catch ( e ) { name = res && res . name ? res . name : 'user_script' ; result = new StoreError ( null , 'error running script (call to %s): %s' , name , e . message ) ; } if ( typeof result === 'boolean' ) { result = Number ( result ) ; } // TODO: check the return value is not an object!!! // var err = ( result instanceof Error ) ; if ( err ) result = result . message ; process . send ( { err : err , data : result , str : ( result instanceof String ) } ) ; }
Run a script.

@param script The compiled script function.
@param args The script arguments.
Run a script .