forked from sass/node-sass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender.js
34 lines (27 loc) · 903 Bytes
/
render.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
32
33
34
var sass = require('../sass'),
chalk = require('chalk'),
fs = require('fs');
function render(options, emitter) {
sass.render({
file: options.inFile,
includePaths: options.includePaths,
outputStyle: options.outputStyle,
sourceComments: options.sourceComments,
success: function(css) {
emitter.emit('warn', chalk.green('Rendering Complete, saving .css file...'));
fs.writeFile(options.outFile, css, function(err) {
if (err) { return emitter.emit('error', chalk.red('Error: ' + err)); }
emitter.emit('warn', chalk.green('Wrote CSS to ' + options.outFile));
emitter.emit('write', err, options.outFile, css);
});
if (options.stdout) {
emitter.emit('log', css);
}
emitter.emit('render', css);
},
error: function(error) {
emitter.emit('error', error);
}
});
}
module.exports = render;