<commit_before>var fs       = require('fs'),
    nodeSass = require('node-sass');

module.exports = {
    run: function( next ){

        if( global.chokidarFileChangePath ){
            if(global.chokidarFileChangePath.indexOf('.scss') === -1 ){
                global.log.general( 'Not a sass file, skipping this module' );
                return next();
            }
        }

        var scssPath    = global.pwd + global.current_module.input_path,
            outputPath  = global.pwd + global.current_module.target;

        nodeSass.render({
            file: scssPath,
            outFile: outputPath,
            outputStyle: global.current_module.outputStyle,
            sourceComments: global.current_module.sourceComments
        }, function( err, result ){

            //this is the complete function that runs after the css file has been written to the buffer
            if( err ){
                global.log.error('ERROR:');
                global.log.general( err );
                return global.log.general( '^^^ Sorry there was an error compiling the scss file ^^^' );
            }

            fs.writeFile(outputPath, result.css.toString() , function(err) {
                global.log.general( 'Built css file to: ' + outputPath );
                return next();
            });
        });
    },

    help: function(){
        var helps = [
            'The sass std is exactly the same as the less std, except as the name suggests... it is for sass.',<commit_msg>Added the ability to add static CSS files from bower to sass generate CSS sheet<commit_after>var fs       = require('fs'),
    nodeSass = require('node-sass');

module.exports = {
    run: function( next ){

        if( global.chokidarFileChangePath ){
            if(global.chokidarFileChangePath.indexOf('.scss') === -1 ){
                global.log.general( 'Not a sass file, skipping this module' );
                return next();
            }
        }

        var scssPath    = global.pwd + global.current_module.input_path,
            outputPath  = global.pwd + global.current_module.target;

        nodeSass.render({
            file: scssPath,
            outFile: outputPath,
            outputStyle: global.current_module.outputStyle,
            sourceComments: global.current_module.sourceComments
        }, function( err, result ){

            //this is the complete function that runs after the css file has been written to the buffer
            if( err ){
                global.log.error('ERROR:');
                global.log.general( err );
                return global.log.general( '^^^ Sorry there was an error compiling the scss file ^^^' );
            }

            fs.writeFile(outputPath, result.css.toString() , function(err) {
                global.log.general( 'Built css file to: ' + outputPath );

                if( typeof global.current_module.include_css === 'object' ){
                    if( global.current_module.include_css.length  > 0){
                        var i;
                        for(i = 0 ; i < global.current_module.include_css.length ; ++ i){
                            global.current_module.include_css[i] = global.pwd + global.current_module.include_css[i];
                        }

                        global.log.general( 'Adding additional CSS files to the compiled SASS generated CSS file: ' );
                        global.log.general(  global.current_module.include_css );

                        var addOnCSS = [outputPath].concat( global.current_module.include_css );

                        //check all the js files actually exist
                        for(i=0;i<addOnCSS.length ; ++i){
                            try{
                                fs.statSync( addOnCSS[i] )
                            } catch( err ){
                                //err = no files, log error and abort
                                logTime( 'ERROR: CSS file not found in the sass_std module.' );
                                global.log.general( err );
                                process.exit();
                            }
                        }

                        //now we have built the all.css, append the bower component specific stuff, eg ng-dialog
                        require('concat-files')( addOnCSS, outputPath, function() {
                            global.log.general( 'CSS files concatenated with the generate css file.' );
                            return next();
                        });
                    } else {
                        return next();
                    }
                } else {
                    return next();
                }
            });
        });
    },

    help: function(){
        var helps = [
            'The sass std is exactly the same as the less std, except as the name suggests... it is for sass.',
{'fraction_non_alphanumeric': 0.09804727646454266, 'fraction_numerical': 0.0010277492291880781, 'mean_word_length': 1.4065281899109792, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1842258', 'n_tokens_mistral': 1235, 'n_tokens_neox': 1167, 'n_words': 335}