Skip to content

Commit

Permalink
automatically include 'nib' if installed
Browse files Browse the repository at this point in the history
  • Loading branch information
MSNexploder committed May 16, 2011
1 parent 5f1e47f commit 183af77
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/brunch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(function() {
var colors, expressProcess, fileUtil, fs, helpers, package, path, root, spawn, stitch, stylus, timeouts, _;
var colors, expressProcess, fileUtil, fs, helpers, nibAvailable, package, path, root, spawn, stitch, stylus, timeouts, _;
root = __dirname + "/../";
fs = require('fs');
path = require('path');
Expand All @@ -14,6 +14,15 @@
expressProcess = {};
package = {};
timeouts = {};
nibAvailable = (function() {
try {
if (require('nib')) {
return true;
}
} catch (error) {
return false;
}
})();
exports["new"] = function(options, callback) {
var projectTemplatePath;
exports.options = options;
Expand Down Expand Up @@ -141,7 +150,7 @@
if (err != null) {
return helpers.log(colors.lred('stylus err: ' + err));
} else {
return stylus(data).set('filename', main_file_path).set('compress', true).include(path.join(exports.options.brunchPath, 'src')).render(function(err, css) {
return stylus(data).set('filename', main_file_path).set('compress', true).include(path.join(exports.options.brunchPath, 'src')).include(nibAvailable ? require('nib').path : '').render(function(err, css) {
if (err != null) {
return helpers.log(colors.lred('stylus err: ' + err));
} else {
Expand Down
7 changes: 7 additions & 0 deletions src/brunch.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ package = {}
# TODO in future this issues should be handled by a clean dir/file watcher
timeouts = {}

# cache if nib is available
nibAvailable = try
true if require('nib')
catch error
false

# project skeleton generator
exports.new = (options, callback) ->
exports.options = options
Expand Down Expand Up @@ -166,6 +172,7 @@ exports.compileStylus = ->
.set('filename', main_file_path)
.set('compress', true)
.include(path.join(exports.options.brunchPath, 'src'))
.include(if nibAvailable then require('nib').path else '')
.render (err, css) ->
if err?
helpers.log colors.lred('stylus err: ' + err)
Expand Down

0 comments on commit 183af77

Please sign in to comment.