Code coverage report for lib/tasks/jsminify.js

Statements: 100% (8 / 8)      Branches: 100% (6 / 6)      Functions: 100% (2 / 2)      Lines: 100% (8 / 8)     

All files » lib/tasks/ » jsminify.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29          1                   1   55 55 2 1   2   53        
/*
 * Copyright (c) 2011-2012, Yahoo! Inc.  All rights reserved.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */
var yuglify = require('yuglify');
 
/**
 * Minify JS.
 *
 * @param options {Object} Task options.
 * @param options.config {Object} Minify options.
 * @param blob {Object} Incoming blob.
 * @param done {Function} Callback on task completion.
 */
exports.jsminify = function (options, blob, done) {
    //Using the default config
    yuglify.jsmin(blob.result, function(err, smashed) {
        if (err) {
            if (options.callback) {
                options.callback(err);
            }
            done('Minify failed, ' + (blob.name || 'file') + ' unparseable');
        } else {
            done(null, new blob.constructor(smashed, blob));
        }
    });
};