34 lines
1.0 KiB
JavaScript
Executable File
34 lines
1.0 KiB
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 = process.argv[2] && path.join(process.cwd(), process.argv[2]),
|
|
output = process.argv[3] && path.join(process.cwd(), process.argv[3]);
|
|
|
|
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);
|
|
if (less.parser.error) {
|
|
process.stdio.writeError(less.parser.error.message);
|
|
} else {
|
|
css = tree.toCSS([], {frames: []});
|
|
if (output) {
|
|
fd = fs.openSync(output, "w");
|
|
fs.writeSync(fd, css, 0, "utf8");
|
|
} else {
|
|
sys.print(css);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|