diff --git a/lib/compass.js b/lib/compass.js index 72223a6..83c0eb0 100644 --- a/lib/compass.js +++ b/lib/compass.js @@ -22,6 +22,7 @@ var defaults = { require: false, logging: true, load_all: false, + env_path:[], project: process.cwd(), bundle_exec: false, debug: false, @@ -59,9 +60,9 @@ module.exports = function(files, opts, callback) { // check command exist if (opts.bundle_exec) { - compassExecutable = helpers.command('bundle', callback); + compassExecutable = helpers.command('bundle', opts.env_path,callback); } else { - compassExecutable = helpers.command(compassExecutable, callback); + compassExecutable = helpers.command(compassExecutable, opts.env_path, callback); } if (!compassExecutable) { diff --git a/lib/helpers.js b/lib/helpers.js index 7c41e5c..665a7b5 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -1,16 +1,25 @@ 'use strict'; var which = require('which').sync; +var isWindows = process.platform === 'win32' || + process.env.OSTYPE === 'cygwin' || + process.env.OSTYPE === 'msys'; +var COLON = isWindows ? ';' : ':'; module.exports.isArray = function(obj) { return Object.prototype.toString.call(obj) === '[object Array]'; }; -module.exports.command = function(cmd, callback) { +module.exports.command = function(cmd, env_path,callback) { var command; - + var opt; + if(env_path.length>0){ + opt = { + path:env_path.join(COLON) + }; + } try { - command = which(cmd); + command = which(cmd, opt); } catch (err) { if (callback) {