added coffee --lint to the self-compiler's resume

This commit is contained in:
Jeremy Ashkenas
2010-02-12 23:09:57 -05:00
parent e02bedcf82
commit d9fba94983
2 changed files with 42 additions and 6 deletions

View File

@@ -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;