plugins/lib/child.js
function compile (extension, content, options, fn) {
    // allow optional options argument
    if (_.isFunction(options)) {
      fn = options;
      options = {};
    }

    var config = _.clone(compile.configuration)
      , args = flags.slice(0)
      , buffer = ''
      , errors = ''
      , compressor;

    if (compile.configuration.type) {
      config.type = extension;
    }

    // generate the --key value options, both the key and the value should added
    // seperately to the `args` array or the child_process will chocke.
    Object.keys(config).filter(function filter (option) {
      return config[option];
    }).forEach(function format (option) {
      var bool = _.isBoolean(config[option]);

      if (!bool || config[option]) {
        args.push('--' + option);
        if (!bool) args.push(config[option]);
      }
    });

    // apply the configuration
    _.extend(config, options);

    // spawn the shit and set the correct encoding
    compressor = spawn(type, args);
    compressor.stdout.setEncoding('utf8');
    compressor.stderr.setEncoding('utf8');

    /**
     * Buffer up the results so we can concat them once the compression is
     * finished.
     *
     * @param {Buffer} chunk
     * @api private
     */

    compressor.stdout.on('data', function data (chunk) {
      buffer += chunk;
    });

    compressor.stderr.on('data', function data (err) {
      errors += err;
    });

    /**
     * The compressor has finished can we now process the data and see if it was
     * a success.
     *
     * @param {Number} code
     * @api private
     */

    compressor.on('close', function close (code) {
      // invalid states
      if (errors.length) return fn(new Error(errors));
      if (code !== 0) return fn(new Error('process exited with code ' + code));
      if (!buffer.length) return fn(new Error('no data returned ' + type + args));

      // correctly processed the data
      fn(null, buffer);
    });

    // write out the content that needs to be minified
    compressor.stdin.end(content);
  }
function compile (extension, content, options, fn) {
    // allow optional options argument
    if (_.isFunction(options)) {
      fn = options;
      options = {};
    }

    var config = _.clone(compile.configuration)
      , args = flags.slice(0)
      , buffer = ''
      , errors = ''
      , compressor;

    if (compile.configuration.type) {
      config.type = extension;
    }

    // generate the --key value options, both the key and the value should added
    // seperately to the `args` array or the child_process will chocke.
    Object.keys(config).filter(function filter (option) {
      return config[option];
    }).forEach(function format (option) {
      var bool = _.isBoolean(config[option]);

      if (!bool || config[option]) {
        args.push('--' + option);
        if (!bool) args.push(config[option]);
      }
    });

    // apply the configuration
    _.extend(config, options);

    // spawn the shit and set the correct encoding
    compressor = spawn(type, args);
    compressor.stdout.setEncoding('utf8');
    compressor.stderr.setEncoding('utf8');

    /**
     * Buffer up the results so we can concat them once the compression is
     * finished.
     *
     * @param {Buffer} chunk
     * @api private
     */

    compressor.stdout.on('data', function data (chunk) {
      buffer += chunk;
    });

    compressor.stderr.on('data', function data (err) {
      errors += err;
    });

    /**
     * The compressor has finished can we now process the data and see if it was
     * a success.
     *
     * @param {Number} code
     * @api private
     */

    compressor.on('close', function close (code) {
      // invalid states
      if (errors.length) return fn(new Error(errors));
      if (code !== 0) return fn(new Error('process exited with code ' + code));
      if (!buffer.length) return fn(new Error('no data returned ' + type + args));

      // correctly processed the data
      fn(null, buffer);
    });

    // write out the content that needs to be minified
    compressor.stdin.end(content);
  }
function compile ( extension , content , options , fn ) { // allow optional options argument if ( _ . isFunction ( options ) ) { fn = options ; options = { } ; } var config = _ . clone ( compile . configuration ) , args = flags . slice ( 0 ) , buffer = '' , errors = '' , compressor ; if ( compile . configuration . type ) { config . type = extension ; } // generate the --key value options, both the key and the value should added // seperately to the `args` array or the child_process will chocke. Object . keys ( config ) . filter ( function filter ( option ) { return config [ option ] ; } ) . forEach ( function format ( option ) { var bool = _ . isBoolean ( config [ option ] ) ; if ( ! bool || config [ option ] ) { args . push ( '--' + option ) ; if ( ! bool ) args . push ( config [ option ] ) ; } } ) ; // apply the configuration _ . extend ( config , options ) ; // spawn the shit and set the correct encoding compressor = spawn ( type , args ) ; compressor . stdout . setEncoding ( 'utf8' ) ; compressor . stderr . setEncoding ( 'utf8' ) ; /**
     * Buffer up the results so we can concat them once the compression is
     * finished.
     *
     * @param {Buffer} chunk
     * @api private
     */ compressor . stdout . on ( 'data' , function data ( chunk ) { buffer += chunk ; } ) ; compressor . stderr . on ( 'data' , function data ( err ) { errors += err ; } ) ; /**
     * The compressor has finished can we now process the data and see if it was
     * a success.
     *
     * @param {Number} code
     * @api private
     */ compressor . on ( 'close' , function close ( code ) { // invalid states if ( errors . length ) return fn ( new Error ( errors ) ) ; if ( code !== 0 ) return fn ( new Error ( 'process exited with code ' + code ) ) ; if ( ! buffer . length ) return fn ( new Error ( 'no data returned ' + type + args ) ) ; // correctly processed the data fn ( null , buffer ) ; } ) ; // write out the content that needs to be minified compressor . stdin . end ( content ) ; }
Delegrate all the hard core processing to the vendor file.

@param {String} extension file extenstion
@param {String} content file contents
@param {Object} options options
@param {Function} fn error first callback
@api public
Delegrate all the hard core processing to the vendor file .