src/bin.js
/**
 * Compile all compilation units from the given configuration files.
 *
 * @private
 *
 * @param {Array<string>} cliArguments All CLI arguments that are used during the command line invocation for this
 *        script.
 */
Compile all compilation units from the given configuration files.
@private

@param {Array} cliArguments All CLI arguments that are used during the command line invocation for this
script.
Compile all compilation units from the given configuration files . @private @param { Array } cliArguments All CLI arguments that are used during the command line invocation for this script .
function compile (cliArguments) {
    var parsedCliArgs = {};
    var ccbuild = new CCBuild(cliArguments);
    ccbuild.on('argsError', function (err) {
        CLI.getSelfName().then(function (selfName) {
            console.error(err + '\n');
            console.error('For more information call ' + selfName + ' --help');
            process.exit(2);
        }).catch(function (err) {
            console.error(err);
            process.exit(2);
        });
    });
    ccbuild.on('compilerPath', function (compilerPath) {
        console.log(compilerPath);
        process.exit(0);
    });
    ccbuild.on('contribPath', function (contribPath) {
        console.log(contribPath);
        process.exit(0);
    });
    ccbuild.on('argsParsed', function (parsedArgs) {
        parsedCliArgs.args = parsedArgs;
    });
    ccbuild.on('configError', function (err) {
        console.error(err);
        process.exit(1);
    });
    ccbuild.on('circularDependencyError', function (err) {
        console.error(err);
    });
    ccbuild.on('compilationError', function (compilationUnit, err) {
        errorDetected = true;
        if (!parsedCliArgs.args.ignoreErrors) {
            console.error(getHeading(compilationUnit));
            console.error(err);
        }
        if (parsedCliArgs.args.stopOnError) process.exit(1);
    });
    ccbuild.on('compiled', function (compilationUnit, stdout, stderr) {
        if (!parsedCliArgs.args.ignoreCompiledCode || (!parsedCliArgs.args.ignoreWarnings && stderr)) {
            console.log(getHeading(compilationUnit));
        }
        if (!parsedCliArgs.args.ignoreCompiledCode) {
            console.log(stdout + '\n');
        }
        if (!parsedCliArgs.args.ignoreWarnings && stderr) {
            console.error(stderr);
        }
        if (parsedCliArgs.args.stopOnWarning && stderr) {
            errorDetected = true;
            process.exit(1);
        }
    });
    var printAndExit = function (message) {
        console.log(message);
        process.exit(0);
    };
    ccbuild.on('help', printAndExit);
    ccbuild.on('version', printAndExit);
    ccbuild.on('configHelp', printAndExit);
    ccbuild.on('closureHelp', printAndExit);
    ccbuild.on('closureVersion', printAndExit);
}
function compile ( cliArguments ) { var parsedCliArgs = { } ; var ccbuild = new CCBuild ( cliArguments ) ; ccbuild . on ( 'argsError' , function ( err ) { CLI . getSelfName ( ) . then ( function ( selfName ) { console . error ( err + '\n' ) ; console . error ( 'For more information call ' + selfName + ' --help' ) ; process . exit ( 2 ) ; } ) . catch ( function ( err ) { console . error ( err ) ; process . exit ( 2 ) ; } ) ; } ) ; ccbuild . on ( 'compilerPath' , function ( compilerPath ) { console . log ( compilerPath ) ; process . exit ( 0 ) ; } ) ; ccbuild . on ( 'contribPath' , function ( contribPath ) { console . log ( contribPath ) ; process . exit ( 0 ) ; } ) ; ccbuild . on ( 'argsParsed' , function ( parsedArgs ) { parsedCliArgs . args = parsedArgs ; } ) ; ccbuild . on ( 'configError' , function ( err ) { console . error ( err ) ; process . exit ( 1 ) ; } ) ; ccbuild . on ( 'circularDependencyError' , function ( err ) { console . error ( err ) ; } ) ; ccbuild . on ( 'compilationError' , function ( compilationUnit , err ) { errorDetected = true ; if ( ! parsedCliArgs . args . ignoreErrors ) { console . error ( getHeading ( compilationUnit ) ) ; console . error ( err ) ; } if ( parsedCliArgs . args . stopOnError ) process . exit ( 1 ) ; } ) ; ccbuild . on ( 'compiled' , function ( compilationUnit , stdout , stderr ) { if ( ! parsedCliArgs . args . ignoreCompiledCode || ( ! parsedCliArgs . args . ignoreWarnings && stderr ) ) { console . log ( getHeading ( compilationUnit ) ) ; } if ( ! parsedCliArgs . args . ignoreCompiledCode ) { console . log ( stdout + '\n' ) ; } if ( ! parsedCliArgs . args . ignoreWarnings && stderr ) { console . error ( stderr ) ; } if ( parsedCliArgs . args . stopOnWarning && stderr ) { errorDetected = true ; process . exit ( 1 ) ; } } ) ; var printAndExit = function ( message ) { console . log ( message ) ; process . exit ( 0 ) ; } ; ccbuild . on ( 'help' , printAndExit ) ; ccbuild . on ( 'version' , printAndExit ) ; ccbuild . on ( 'configHelp' , printAndExit ) ; ccbuild . on ( 'closureHelp' , printAndExit ) ; ccbuild . on ( 'closureVersion' , printAndExit ) ; }
Compile all compilation units from the given configuration files.
Compile all compilation units from the given configuration files .