Permalink
Browse files

Added LESS support.

  • Loading branch information...
1 parent 6421938 commit 33bd9393eb160f902c6ca95da9fe59b6c75df6ef @meowgorithm committed May 24, 2012
Showing with 40 additions and 2 deletions.
  1. +1 −1 README.md
  2. +28 −0 lib/cakewalk.js
  3. +9 −0 lib/errors.js
  4. +2 −1 package.json
View
@@ -1,6 +1,6 @@
# Cakewalk
-Cakewalk walks a given directory looking for CoffeeScript, Stylus, and Jade files, watching them for changes and compiling them when they change.
+Cakewalk walks a given directory looking for CoffeeScript, Stylus, LESS, and Jade files, watching them for changes and compiling them when they change.
## Install
npm install -g cakewalk
View
@@ -1,12 +1,14 @@
var fs = require('fs');
var coffee = require('coffee-script');
var stylus = require('stylus');
+var less = require('less');
var jade = require('jade');
var colors = require('colors');
var walk = require('./walk.js').walk;
var BuildError = require('./errors.js').BuildError;
var CoffeeScriptError = require('./errors.js').CoffeeScriptError;
var StylusError = require('./errors.js').StylusError;
+var LessError = require('./errors.js').LessError;
var JadeError = require('./errors.js').JadeError;
@@ -116,6 +118,29 @@ function StylusBuilder(source, destination) {
/**
+ * Compiles LESS into CSS.
+ */
+function LessBuilder(source, destination) {
+
+ destination = destination || replaceExtension(source, 'css');
+
+ var builder = new Builder(source, destination, function(input) {
+ var output;
+ less.render(input, {}, function(err, css) {
+ if(err) {
+ throw new LessError(err.message, source);
+ }
+ output = css;
+ });
+ return output;
+ });
+
+ this.start = builder.start;
+ this.stop = builder.stop;
+}
+
+
+/**
* Compiles Jade into HTML.
*/
function JadeBuilder(source, destination) {
@@ -176,6 +201,7 @@ Cakewalker.IGNORE_PATTERN = new RegExp(/(?:\.git|\.svn|node_modules|\/_)/);
Cakewalker.COFFEE_PATTERN = new RegExp(/\.coffee$/);
Cakewalker.STYLUS_PATTERN = new RegExp(/\.styl$/);
+Cakewalker.LESS_PATTERN = new RegExp(/\.less$/);
Cakewalker.JADE_PATTERN = new RegExp(/\.jade$/);
Cakewalker.prototype = {
@@ -200,6 +226,8 @@ Cakewalker.prototype = {
self.builders.push(new CoffeeBuilder(file));
} else if(Cakewalker.STYLUS_PATTERN.test(file)) {
self.builders.push(new StylusBuilder(file));
+ } else if(Cakewalker.LESS_PATTERN.test(file)) {
+ self.builders.push(new LessBuilder(file));
} else if(Cakewalker.JADE_PATTERN.test(file)) {
self.builders.push(new JadeBuilder(file));
}
View
@@ -29,6 +29,15 @@ exports.StylusError = function(message, sourceFile) {
exports.StylusError.prototype = new BuildError();
+exports.LessError = function(message, sourceFile) {
+ this.message = message;
+ this.type = 'Less';
+ this.sourceFile = sourceFile;
+}
+
+exports.LessError.prototype = new BuildError();
+
+
exports.JadeError = function(message, sourceFile) {
this.message = message;
this.type = 'Jade';
View
@@ -1,7 +1,7 @@
{
"name": "cakewalk",
"preferGlobal": true,
- "version": "0.1.3",
+ "version": "0.2.0",
"author": "Christian Rocha <christian.rocha@gmail.com>",
"bin": {
"cakewalk": "./bin/cakewalk"
@@ -16,6 +16,7 @@
"dependencies": {
"coffee-script": "*",
"stylus": "*",
+ "less": "*",
"jade": "*",
"colors": "0.6.x",
"optimist": "0.3.x"

0 comments on commit 33bd939

Please sign in to comment.