1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | var regex = {
|
11 | compress: /(\.|-)min\.css$/,
|
12 | handle: /\.css(\.map)?$/,
|
13 | sourceMap: /\.css\.map$/
|
14 | };
|
15 |
|
16 | module.exports = {
|
17 | isCompressedPath: function(pathname) {
|
18 | return regex.compress.test(pathname);
|
19 | },
|
20 | isSourceMap: function( pathname ){
|
21 | return regex.sourceMap.test(pathname);
|
22 | },
|
23 | isValidPath: function(pathname) {
|
24 | return regex.handle.test(pathname);
|
25 | },
|
26 | lessError: function(err) {
|
27 |
|
28 | module.exports.log('LESS ' + err.type + ' error', err.message, 'error');
|
29 | module.exports.log('LESS File', err.filename + ' ' + err.line + ':' + err.column, 'error');
|
30 | },
|
31 | log: function(key, value, type) {
|
32 |
|
33 | if(type !== 'error') {
|
34 | return;
|
35 | }
|
36 |
|
37 | console[type](" \u001b[90m%s :\u001b[0m \u001b[36m%s\u001b[0m", key, value);
|
38 | },
|
39 | logDebug: function(key, value, type) {
|
40 | switch(type) {
|
41 | case 'log':
|
42 | case 'info':
|
43 | case 'error':
|
44 | case 'warn':
|
45 | break;
|
46 | default:
|
47 | type = 'log';
|
48 | }
|
49 |
|
50 | console[type](" \u001b[90m%s :\u001b[0m \u001b[36m%s\u001b[0m", key, value);
|
51 | },
|
52 | maybeCompressedSource: function(pathname) {
|
53 | return (regex.compress.test(pathname)
|
54 | ? pathname.replace(regex.compress, '.less')
|
55 | : pathname.replace('.css', '.less')
|
56 | );
|
57 | }
|
58 | };
|