Skip to content

Commit

Permalink
Just add stylus as a submodule rather than installing it at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
marcuswestin committed Apr 30, 2012
1 parent cc10585 commit dd2cd46
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 27 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -20,6 +20,7 @@
"socket.io": "0.9.6",
"dom": "0.1.3",
"std": "0.1.34",
"stylus": "0.25.0",
"colors": "0.6.0-1"
},
"devDependencies": {
Expand Down
29 changes: 2 additions & 27 deletions src/resolver.js
Expand Up @@ -269,38 +269,13 @@ var cssPreprocessors = {
callback(null, css)
},
'stylesheet/less': function(href, lessContent, callback) {
try { require('less').render(lessContent, callback) }
catch(err) {
installNodeModule('less', function(err) {
if (err) { return callback(err, null) }
require('less').render(lessContent, callback)
})
}
require('less').render(lessContent, callback)
},
'stylesheet/stylus': function(href, stylusContent, callback) {
try { require('stylus').render(stylusContent, { filename:href }, callback) }
catch(err) {
installNodeModule('stylus', function(err) {
if (err) { return callback(err, null) }
require('stylus').render(stylusContent, { filename:href }, callback)
})
}
require('stylus').render(stylusContent, { filename:href }, callback)
}
}

var installNodeModule = function(name, callback) {
var cwd = process.cwd(),
command = 'sudo npm install '+name
console.error("attempting to install node module", name, "...")
console.error(command)
process.chdir(__dirname + '/..')
exec(command, function(err, stdout, stderr) {
process.chdir(cwd)
console.error(err ? "error" : "success", "installing node module", name)
callback(err)
})
}

/*******************************
* Imports (imports and files) *
*******************************/
Expand Down

0 comments on commit dd2cd46

Please sign in to comment.