Fix bin/lessc

One more time, had to replace fs.open call with fs.readFile.
This commit is contained in:
Felix Geisendörfer 2010-10-05 17:02:14 +08:00 committed by Alexis Sellier
parent ef71bb0db2
commit 66887882f5

View File

@ -62,37 +62,33 @@ if (! input) {
process.exit(1); process.exit(1);
} }
fs.stat(input, function (e, stats) { fs.readFile(input, 'utf-8', function (e, data) {
if (e) { if (e) {
sys.puts("lessc: " + e.message); sys.puts("lessc: " + e.message);
process.exit(1); process.exit(1);
} }
fs.open(input, process.O_RDONLY, stats.mode, function (e, fd) {
fs.read(fd, stats.size, 0, "utf8", function (e, data) { new(less.Parser)({
new(less.Parser)({ paths: [path.dirname(input)],
paths: [path.dirname(input)], optimization: options.optimization,
optimization: options.optimization, filename: input
filename: input }).parse(data, function (err, tree) {
}).parse(data, function (err, tree) { if (err) {
if (err) { less.writeError(err, options);
less.writeError(err, options); process.exit(1);
process.exit(1); } else {
try {
css = tree.toCSS({ compress: options.compress });
if (output) {
fd = fs.openSync(output, "w");
fs.writeSync(fd, css, 0, "utf8");
} else { } else {
try { sys.print(css);
css = tree.toCSS({ compress: options.compress });
if (output) {
fd = fs.openSync(output, "w");
fs.writeSync(fd, css, 0, "utf8");
} else {
sys.print(css);
}
} catch (e) {
less.writeError(e, options);
process.exit(2);
}
} }
}); } catch (e) {
}); less.writeError(e, options);
process.exit(2);
}
}
}); });
}); });