carto/bin/lessc
2010-02-26 18:18:11 -05:00

27 lines
778 B
JavaScript
Executable File

#!/usr/bin/env node
var path = require('path'),
fs = require('fs'),
sys = require('sys');
require.paths.unshift(__dirname, path.join(__dirname, '..'));
var less = require('lib/less/adapters/server');
var input = path.join(process.cwd(), process.argv[2]),
output = path.join(process.cwd(), process.argv[3] ||
input.replace(/\.le?ss$/, '.css'));
var css, fd, tree;
fs.stat(input, function (e, stats) {
fs.open(input, process.O_RDONLY, stats.mode, function (e, fd) {
fs.read(fd, stats.size, 0, "utf8", function (e, data) {
tree = less.parser.parse(data);
css = tree.toCSS([], {frames: []});
fd = fs.openSync(output, "w");
fs.writeSync(fd, css, 0, "utf8");
});
});
});