mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
Merge pull request #340 from steevel/master
Read less-content from stdin
This commit is contained in:
22
bin/lessc
22
bin/lessc
@@ -67,7 +67,7 @@ args = args.filter(function (arg) {
|
||||
});
|
||||
|
||||
var input = args[1];
|
||||
if (input && input[0] != '/') {
|
||||
if (input && input[0] != '/' && input != '-') {
|
||||
input = path.join(process.cwd(), input);
|
||||
}
|
||||
var output = args[2];
|
||||
@@ -82,7 +82,7 @@ if (! input) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
fs.readFile(input, 'utf-8', function (e, data) {
|
||||
var parseLessFile = function (e, data) {
|
||||
if (e) {
|
||||
sys.puts("lessc: " + e.message);
|
||||
process.exit(1);
|
||||
@@ -111,4 +111,20 @@ fs.readFile(input, 'utf-8', function (e, data) {
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
if (input != '-') {
|
||||
fs.readFile(input, 'utf-8', parseLessFile);
|
||||
} else {
|
||||
process.stdin.resume();
|
||||
process.stdin.setEncoding('utf8');
|
||||
|
||||
var buffer = '';
|
||||
process.stdin.on('data', function(data) {
|
||||
buffer += data;
|
||||
});
|
||||
|
||||
process.stdin.on('end', function() {
|
||||
parseLessFile(false, buffer);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user