forked from quaertym/ember-cli-compass-compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compass.js
45 lines (36 loc) · 1.03 KB
/
compass.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
35
36
37
38
39
40
41
42
43
44
45
var dargs = require('dargs');
var EOL = require('os').EOL;
var exec = require('child_process').exec;
var merge = require('lodash-node/modern/objects/merge');
var path = require('path');
var RSVP = require('rsvp');
var sys = require('sys');
function Compass() {
}
Compass.prototype.generateCommand = function(options) {
var ignoredOptions = ['compassCommand'];
var args = dargs(options, ignoredOptions);
var command = [options.compassCommand, 'compile'].concat(args).join(' ');
return command;
};
Compass.prototype.compile = function(srcDir, destDir, options) {
var cssDir = path.join(destDir, 'assets');
merge(options, {
cssDir: cssDir
});
var command = this.generateCommand(options);
return new RSVP.Promise(function(resolve, reject) {
exec(command, function(error, stdout, stderr) {
if (stderr) {
sys.print(stderr + EOL);
}
if (error) {
sys.print(stdout + EOL);
reject(error);
} else {
resolve(cssDir);
}
});
});
};
module.exports = Compass;