composer.js 452 B

1234567891011121314151617181920
  1. 'use strict';
  2. var through = require('through2');
  3. var minify = require('./lib/minify');
  4. module.exports = function(uglify, logger) {
  5. return function(opts) {
  6. var minifier = minify(uglify, logger)(opts);
  7. return through.obj(function(file, encoding, callback) {
  8. var newFile = null;
  9. var err = null;
  10. try {
  11. newFile = minifier(file);
  12. } catch (e) {
  13. err = e;
  14. }
  15. callback(err, newFile);
  16. });
  17. };
  18. };