mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-17 19:11:22 -05:00
Nicer-looking --tokenize, more in line with what Ruby's doing
This commit is contained in:
@@ -55,7 +55,7 @@
|
||||
return posix.cat(source).addCallback(function(code) {
|
||||
var js;
|
||||
if (opts.tokens) {
|
||||
puts(coffee.tokenize(code).join(' '));
|
||||
puts(exports.tokenize(code));
|
||||
} else if (opts.tree) {
|
||||
puts(coffee.tree(code).toString());
|
||||
} else {
|
||||
@@ -83,6 +83,14 @@
|
||||
return posix.write(fd, js);
|
||||
});
|
||||
};
|
||||
// Pretty-print the token stream.
|
||||
exports.tokenize = function tokenize(code) {
|
||||
var strings;
|
||||
strings = coffee.tokenize(code).map(function(token) {
|
||||
return '[' + token[0] + ' ' + token[1].toString().replace(/\n/, '\\n') + ']';
|
||||
});
|
||||
return strings.join(' ');
|
||||
};
|
||||
// Pipe compiled JS through JSLint (requires a working 'jsl' command).
|
||||
exports.lint = function lint(js) {
|
||||
var jsl;
|
||||
|
||||
Reference in New Issue
Block a user