js/src/cli.js
function processInputSync(filepath) {
    var data = null,
        config = this.cfg,
        outfile = config.outfile,
        input;

    // -o passed with no value overwrites
    if (outfile === true || config.replace) {
        outfile = filepath;
    }

    var fileType = getOutputType(outfile, filepath, config.type);

    if (config.editorconfig) {
        var editorconfig_filepath = filepath;

        if (editorconfig_filepath === '-') {
            if (outfile) {
                editorconfig_filepath = outfile;
            } else {
                editorconfig_filepath = 'stdin.' + fileType;
            }
        }

        debug("EditorConfig is enabled for ", editorconfig_filepath);
        config = cc(config).snapshot;
        set_file_editorconfig_opts(editorconfig_filepath, config);
        debug(config);
    }

    if (filepath === '-') {
        input = process.stdin;

        input.setEncoding('utf8');

        input.on('error', function() {
            throw 'Must pipe input or define at least one file.';
        });

        input.on('data', function(chunk) {
            data = data || '';
            data += chunk;
        });

        input.on('end', function() {
            if (data === null) {
                throw 'Must pipe input or define at least one file.';
            }
            makePretty(fileType, data, config, outfile, writePretty); // Where things get beautified
        });

        input.resume();

    } else {
        data = fs.readFileSync(filepath, 'utf8');
        makePretty(fileType, data, config, outfile, writePretty);
    }
}
function processInputSync(filepath) {
    var data = null,
        config = this.cfg,
        outfile = config.outfile,
        input;

    // -o passed with no value overwrites
    if (outfile === true || config.replace) {
        outfile = filepath;
    }

    var fileType = getOutputType(outfile, filepath, config.type);

    if (config.editorconfig) {
        var editorconfig_filepath = filepath;

        if (editorconfig_filepath === '-') {
            if (outfile) {
                editorconfig_filepath = outfile;
            } else {
                editorconfig_filepath = 'stdin.' + fileType;
            }
        }

        debug("EditorConfig is enabled for ", editorconfig_filepath);
        config = cc(config).snapshot;
        set_file_editorconfig_opts(editorconfig_filepath, config);
        debug(config);
    }

    if (filepath === '-') {
        input = process.stdin;

        input.setEncoding('utf8');

        input.on('error', function() {
            throw 'Must pipe input or define at least one file.';
        });

        input.on('data', function(chunk) {
            data = data || '';
            data += chunk;
        });

        input.on('end', function() {
            if (data === null) {
                throw 'Must pipe input or define at least one file.';
            }
            makePretty(fileType, data, config, outfile, writePretty); // Where things get beautified
        });

        input.resume();

    } else {
        data = fs.readFileSync(filepath, 'utf8');
        makePretty(fileType, data, config, outfile, writePretty);
    }
}
function processInputSync ( filepath ) { var data = null , config = this . cfg , outfile = config . outfile , input ; // -o passed with no value overwrites if ( outfile === true || config . replace ) { outfile = filepath ; } var fileType = getOutputType ( outfile , filepath , config . type ) ; if ( config . editorconfig ) { var editorconfig_filepath = filepath ; if ( editorconfig_filepath === '-' ) { if ( outfile ) { editorconfig_filepath = outfile ; } else { editorconfig_filepath = 'stdin.' + fileType ; } } debug ( "EditorConfig is enabled for " , editorconfig_filepath ) ; config = cc ( config ) . snapshot ; set_file_editorconfig_opts ( editorconfig_filepath , config ) ; debug ( config ) ; } if ( filepath === '-' ) { input = process . stdin ; input . setEncoding ( 'utf8' ) ; input . on ( 'error' , function ( ) { throw 'Must pipe input or define at least one file.' ; } ) ; input . on ( 'data' , function ( chunk ) { data = data || '' ; data += chunk ; } ) ; input . on ( 'end' , function ( ) { if ( data === null ) { throw 'Must pipe input or define at least one file.' ; } makePretty ( fileType , data , config , outfile , writePretty ) ; // Where things get beautified } ) ; input . resume ( ) ; } else { data = fs . readFileSync ( filepath , 'utf8' ) ; makePretty ( fileType , data , config , outfile , writePretty ) ; } }
main iterator, {cfg} passed as thisArg of forEach call
main iterator { cfg } passed as thisArg of forEach call