Fix bin/lessc to use less.js and callback-style

nohash
cloudhead 15 years ago
parent f973deec28
commit 9a276481f1

@ -6,7 +6,7 @@ var path = require('path'),
require.paths.unshift(__dirname, path.join(__dirname, '..')); require.paths.unshift(__dirname, path.join(__dirname, '..'));
var less = require('lib/less/adapters/server'); var less = require('lib/less');
var args = process.argv.slice(1); var args = process.argv.slice(1);
args = args.filter(function (arg) { args = args.filter(function (arg) {
@ -42,18 +42,19 @@ fs.stat(input, function (e, stats) {
} }
fs.open(input, process.O_RDONLY, stats.mode, function (e, fd) { fs.open(input, process.O_RDONLY, stats.mode, function (e, fd) {
fs.read(fd, stats.size, 0, "utf8", function (e, data) { fs.read(fd, stats.size, 0, "utf8", function (e, data) {
tree = less.parser.parse(data); less.parser.parse(data, function (err, tree) {
if (less.parser.error) { if (err) {
process.stdio.writeError(less.parser.error.message); process.stdio.writeError(err);
} else {
css = tree.toCSS([], {frames: []});
if (output) {
fd = fs.openSync(output, "w");
fs.writeSync(fd, css, 0, "utf8");
} else { } else {
sys.print(css); css = tree.toCSS([], {frames: []});
if (output) {
fd = fs.openSync(output, "w");
fs.writeSync(fd, css, 0, "utf8");
} else {
sys.print(css);
}
} }
} });
}); });
}); });
}); });

Loading…
Cancel
Save