composer.js 452 B

12345678910111213141516171819
  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. };