-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (27 loc) · 756 Bytes
/
index.js
File metadata and controls
31 lines (27 loc) · 756 Bytes
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
var fs = require('fs');
var path = require('path');
var stylus = require('stylus');
function StylusProcessor(cube) {
this.cube = cube;
}
StylusProcessor.type = 'style';
StylusProcessor.ext = '.styl';
StylusProcessor.prototype.process = function (data, callback) {
var config = this.cube.config;
var root = config.root;
var code = data.code;
var file = data.realPath;
var codeRes;
try {
data.code = stylus.render(code, {compress: data.compress || config.compress});
} catch (e) {
var tmp = e.message.split('\n')[0].split(':');
e.code = 'Stylus_Parse_Error';
e.file = file;
e.line = Number(tmp[1]);
e.column = Number(tmp[2]);
return callback(e);
}
callback(null, data);
};
module.exports = StylusProcessor;