mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-17 11:01:25 -05:00
added coffee --lint to the self-compiler's resume
This commit is contained in:
@@ -54,7 +54,13 @@
|
||||
}
|
||||
opts = this.options;
|
||||
return posix.cat(source).addCallback(function(code) {
|
||||
opts.tokens ? puts(coffee.tokenize(code).join(' ')) : opts.tree ? puts(coffee.tree(code).toString()) : opts.run ? eval(coffee.compile(code)) : opts.print ? puts(coffee.compile(code)) : exports.write_js(source, coffee.compile(code));
|
||||
var js;
|
||||
if (opts.tokens) {
|
||||
puts(coffee.tokenize(code).join(' '));
|
||||
} else {
|
||||
opts.tree ? puts(coffee.tree(code).toString()) : (js = coffee.compile(code));
|
||||
opts.run ? eval(js) : opts.print ? puts(js) : opts.lint ? exports.lint(js) : exports.write_js(source, coffee.compile(code));
|
||||
}
|
||||
return exports.compile_scripts();
|
||||
});
|
||||
};
|
||||
@@ -68,6 +74,23 @@
|
||||
return posix.write(fd, js);
|
||||
});
|
||||
};
|
||||
// Pipe compiled JS through JSLint (requires a working 'jsl' command).
|
||||
exports.lint = function lint(js) {
|
||||
var jsl;
|
||||
jsl = process.createChildProcess('jsl', ['-nologo', '-stdin']);
|
||||
jsl.addListener('output', function(result) {
|
||||
if (result) {
|
||||
return puts(result.replace(/\n/g, ''));
|
||||
}
|
||||
});
|
||||
jsl.addListener('errror', function(result) {
|
||||
if (result) {
|
||||
return puts(result);
|
||||
}
|
||||
});
|
||||
jsl.write(js);
|
||||
return jsl.close();
|
||||
};
|
||||
// Use OptionParser for all the options.
|
||||
exports.parse_options = function parse_options() {
|
||||
var oparser, opts, paths;
|
||||
|
||||
Reference in New Issue
Block a user