src/js/utils/api.js
function analyze(script, clientAnalyses, initParam) {
    var directJSScript = path.resolve(__dirname, "../commands/direct.js");
    var cliArgs = [];
    if (!script) {
        throw new Error("must provide a script to analyze");
    }
    if (!clientAnalyses) {
        throw new Error("must provide an analysis to run");
    }
    clientAnalyses.forEach(function (analysis) {
        cliArgs.push('--analysis');
        cliArgs.push(analysis);
    });
    if (initParam) {
        Object.keys(initParam).forEach(function (k) {
            cliArgs.push('--initParam')
            cliArgs.push(k + ':' + initParam[k]);
        });
    }
    cliArgs.push(script);
    var proc = cp.fork(directJSScript, cliArgs, { silent: true });
    return runChildAndCaptureOutput(proc);
}
function analyze(script, clientAnalyses, initParam) {
    var directJSScript = path.resolve(__dirname, "../commands/direct.js");
    var cliArgs = [];
    if (!script) {
        throw new Error("must provide a script to analyze");
    }
    if (!clientAnalyses) {
        throw new Error("must provide an analysis to run");
    }
    clientAnalyses.forEach(function (analysis) {
        cliArgs.push('--analysis');
        cliArgs.push(analysis);
    });
    if (initParam) {
        Object.keys(initParam).forEach(function (k) {
            cliArgs.push('--initParam')
            cliArgs.push(k + ':' + initParam[k]);
        });
    }
    cliArgs.push(script);
    var proc = cp.fork(directJSScript, cliArgs, { silent: true });
    return runChildAndCaptureOutput(proc);
}
function analyze ( script , clientAnalyses , initParam ) { var directJSScript = path . resolve ( __dirname , "../commands/direct.js" ) ; var cliArgs = [ ] ; if ( ! script ) { throw new Error ( "must provide a script to analyze" ) ; } if ( ! clientAnalyses ) { throw new Error ( "must provide an analysis to run" ) ; } clientAnalyses . forEach ( function ( analysis ) { cliArgs . push ( '--analysis' ) ; cliArgs . push ( analysis ) ; } ) ; if ( initParam ) { Object . keys ( initParam ) . forEach ( function ( k ) { cliArgs . push ( '--initParam' ) cliArgs . push ( k + ':' + initParam [ k ] ) ; } ) ; } cliArgs . push ( script ) ; var proc = cp . fork ( directJSScript , cliArgs , { silent : true } ) ; return runChildAndCaptureOutput ( proc ) ; }
direct analysis of an instrumented file using analysis2 engine
@param {string} script the instrumented script to analyze
@param {string[]} clientAnalyses the analyses to run
@param {object} [initParam] parameter to pass to client init() function
@return promise|Q.promise promise that gets resolved at the end of analysis.  The promise
is resolved with an object with properties:
'exitCode': the exit code from the process doing replay
'stdout': the stdout of the replay process
'stderr': the stderr of the replay process
'result': the result returned by the analysis, if any
direct analysis of an instrumented file using analysis2 engine