๐Ÿ“ฆ EdwonLim / node-less

๐Ÿ“„ debugInfo.js ยท 33 lines
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
32
33(function(module){

    var debugInfo = function(env, ctx) {
        var result="";
        if (env.dumpLineNumbers && !env.compress) {
            switch(env.dumpLineNumbers) {
                case 'comments':
                    result = debugInfo.asComment(ctx);
                    break;
                case 'mediaquery':
                    result = debugInfo.asMediaQuery(ctx);
                    break;
                case 'all':
                    result = debugInfo.asComment(ctx) + debugInfo.asMediaQuery(ctx);
                    break;
            }
        }
        return result;
    };

    debugInfo.asComment = function(ctx) {
        return '/* line ' + ctx.debugInfo.lineNumber + ', ' + ctx.debugInfo.fileName + ' */\n';
    };

    debugInfo.asMediaQuery = function(ctx) {
        return '@media -sass-debug-info{filename{font-family:' +
            ('file://' + ctx.debugInfo.fileName).replace(/([.:/\\])/g, function(a){if(a=='\\') a = '\/'; return '\\' + a}) +
            '}line{font-family:\\00003' + ctx.debugInfo.lineNumber + '}}\n';
    };

    module.exports = debugInfo;

})(module);