Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
compass-compile/lib/compass.js /
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
37 lines (32 sloc)
996 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var exec = require('child_process').exec; | |
| var merge = require('merge'); | |
| var dargs = require('dargs'); | |
| var RSVP = require('rsvp'); | |
| var generateCommand = function(options) { | |
| var compassCommand = options.compassCommand; | |
| var excludes = ['compassCommand']; | |
| var args = dargs(options, { excludes: excludes }); | |
| var command = [compassCommand, 'compile'].concat(args).join(' '); | |
| return command; | |
| }; | |
| function Compass() { | |
| this.defaultOptions = { | |
| compassCommand: 'compass' | |
| }; | |
| } | |
| Compass.prototype.compile = function(options) { | |
| var compassOptions = merge(this.defaultOptions, options || {}); | |
| var command = generateCommand(compassOptions); | |
| return new RSVP.Promise(function(resolve, reject) { | |
| exec(command, function(error, stdout, stderr) { | |
| if (error) { | |
| if (stdout) { console.log(stdout); } | |
| if (stderr) { console.log(stderr); } | |
| reject(error); | |
| } else { | |
| resolve(compassOptions.cssDir); | |
| } | |
| }); | |
| }); | |
| }; | |
| module.exports = Compass; |