Code coverage report for lib/tasks/jsstamp.js

Statements: 100% (14 / 14)      Branches: 100% (10 / 10)      Functions: 100% (2 / 2)      Lines: 100% (14 / 14)     

All files » lib/tasks/ » jsstamp.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 30 31            1 22 22   22 22   22   2 2   2 4 3     2     22   22    
/*
Copyright (c) 2012, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://yuilibrary.com/license/
*/
 
exports.jsstamp = function (options, blob, done) {
    var result, spaces, indent = '';
    options = options || {};
 
    options.prefix = options.prefix || '';
    options.postfix = options.postfix || '';
 
    if (options.strict) {
        //Find the first char position so we can inject "use strict"; at that point
        spaces = blob.result.split('\n')[0].split(' ');
        indent = '';
 
        spaces.forEach(function (ch) {
            if (ch === '') {
                indent += ' ';
            }
        });
        options.prefix += indent + '"use strict";\n';
    }
 
    result = options.prefix + blob.result + options.postfix;
 
    done(null, new blob.constructor(result, blob));
};