mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
unifying the CoffeeScript.compile and CoffeeScript.run apis to be the same -- source code and options hash.
This commit is contained in:
parent
5b9ebd19d5
commit
1cf0326183
9 changed files with 31 additions and 28 deletions
|
@ -37,7 +37,7 @@
|
|||
return compile_stdio();
|
||||
}
|
||||
if (options.eval) {
|
||||
return compile_script('unknown', sources[0]);
|
||||
return compile_script('console', sources[0]);
|
||||
}
|
||||
if (!(sources.length)) {
|
||||
return usage();
|
||||
|
@ -80,17 +80,18 @@
|
|||
// in common. If evaluating the script directly sets `__filename`, `__dirname`
|
||||
// and `module.filename` to be correct relative to the script's path.
|
||||
compile_script = function compile_script(source, code) {
|
||||
var js, o;
|
||||
var code_opts, js, o;
|
||||
o = options;
|
||||
code_opts = compile_options(source);
|
||||
try {
|
||||
if (o.tokens) {
|
||||
return print_tokens(CoffeeScript.tokens(code));
|
||||
} else if (o.nodes) {
|
||||
return puts(CoffeeScript.nodes(code).toString());
|
||||
} else if (o.run) {
|
||||
return CoffeeScript.run(code, source, compile_options());
|
||||
return CoffeeScript.run(code, code_opts);
|
||||
} else {
|
||||
js = CoffeeScript.compile(code, compile_options(source));
|
||||
js = CoffeeScript.compile(code, code_opts);
|
||||
if (o.compile) {
|
||||
return write_js(source, js);
|
||||
} else if (o.lint) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue