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