bin/pretty.js
function showResults(files, formattedFiles, unformattedFiles, errors) {
    const formattedCount = formattedFiles.length;
    const unformattedCount = unformattedFiles.length;
    const errorCount = errors.length;
    const filesCount = files.length;
    const okCount = filesCount - formattedCount - unformattedCount - errorCount;

    if (okCount > 0 && !simplifyOutput) {
        console.log(okCount + ' of ' + filesCount + ' files already correct.');
    }

    if (formattedCount > 0) {
        if (!simplifyOutput) {
            console.log('Formatted ' + formattedCount + ' of ' + filesCount + ' files:');
        }
        for (const sourcePath of formattedFiles) {
            if (simplifyOutput) {
                console.log(sourcePath);
            } else {
                console.log('    - ' + sourcePath);
            }
        }
    }

    if (unformattedCount > 0) {
        // Should only happen when !fixMode
        console.error(unformattedCount + ' of ' + filesCount + ' files need formatting:');
        for (const sourcePath of unformattedFiles) {
            console.error('    - ' + sourcePath);
        }
        process.exitCode = 1;
    }

    if (errorCount > 0) {
        console.error('\x1b[32mErrors occured processing ' + errorCount + ' of ' + filesCount + ' files.\x1b[m');
        process.exitCode = -1;
    }

    return { formattedFiles, unformattedFiles };
}
function showResults(files, formattedFiles, unformattedFiles, errors) {
    const formattedCount = formattedFiles.length;
    const unformattedCount = unformattedFiles.length;
    const errorCount = errors.length;
    const filesCount = files.length;
    const okCount = filesCount - formattedCount - unformattedCount - errorCount;

    if (okCount > 0 && !simplifyOutput) {
        console.log(okCount + ' of ' + filesCount + ' files already correct.');
    }

    if (formattedCount > 0) {
        if (!simplifyOutput) {
            console.log('Formatted ' + formattedCount + ' of ' + filesCount + ' files:');
        }
        for (const sourcePath of formattedFiles) {
            if (simplifyOutput) {
                console.log(sourcePath);
            } else {
                console.log('    - ' + sourcePath);
            }
        }
    }

    if (unformattedCount > 0) {
        // Should only happen when !fixMode
        console.error(unformattedCount + ' of ' + filesCount + ' files need formatting:');
        for (const sourcePath of unformattedFiles) {
            console.error('    - ' + sourcePath);
        }
        process.exitCode = 1;
    }

    if (errorCount > 0) {
        console.error('\x1b[32mErrors occured processing ' + errorCount + ' of ' + filesCount + ' files.\x1b[m');
        process.exitCode = -1;
    }

    return { formattedFiles, unformattedFiles };
}
function showResults ( files , formattedFiles , unformattedFiles , errors ) { const formattedCount = formattedFiles . length ; const unformattedCount = unformattedFiles . length ; const errorCount = errors . length ; const filesCount = files . length ; const okCount = filesCount - formattedCount - unformattedCount - errorCount ; if ( okCount > 0 && ! simplifyOutput ) { console . log ( okCount + ' of ' + filesCount + ' files already correct.' ) ; } if ( formattedCount > 0 ) { if ( ! simplifyOutput ) { console . log ( 'Formatted ' + formattedCount + ' of ' + filesCount + ' files:' ) ; } for ( const sourcePath of formattedFiles ) { if ( simplifyOutput ) { console . log ( sourcePath ) ; } else { console . log ( '    - ' + sourcePath ) ; } } } if ( unformattedCount > 0 ) { // Should only happen when !fixMode console . error ( unformattedCount + ' of ' + filesCount + ' files need formatting:' ) ; for ( const sourcePath of unformattedFiles ) { console . error ( '    - ' + sourcePath ) ; } process . exitCode = 1 ; } if ( errorCount > 0 ) { console . error ( '\x1b[32mErrors occured processing ' + errorCount + ' of ' + filesCount + ' files.\x1b[m' ) ; process . exitCode = - 1 ; } return { formattedFiles , unformattedFiles } ; }
Display results to user
Display results to user