mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
#2490 -- implementing a conditional in terms of the guard style.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// Generated by CoffeeScript 1.6.1
|
||||
(function() {
|
||||
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, exists, forkNode, fs, helpers, hidden, joinTimeout, lint, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, sourceCode, sources, spawn, timeLog, unwatchDir, usage, version, wait, watch, watchDir, watchers, writeJs, _ref;
|
||||
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, exists, forkNode, fs, helpers, hidden, joinTimeout, lint, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, runScripts, sourceCode, sources, spawn, timeLog, unwatchDir, usage, version, wait, watch, watchDir, watchers, writeJs, _ref;
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
@@ -49,32 +49,26 @@
|
||||
optionParser = null;
|
||||
|
||||
exports.run = function() {
|
||||
var literals, source, _i, _len, _results;
|
||||
parseOptions();
|
||||
if (opts.nodejs) {
|
||||
return forkNode();
|
||||
}
|
||||
if (opts.help) {
|
||||
return usage();
|
||||
}
|
||||
if (opts.version) {
|
||||
return version();
|
||||
}
|
||||
if (opts.interactive) {
|
||||
return require('./repl').start();
|
||||
}
|
||||
if (opts.watch && !fs.watch) {
|
||||
return printWarn("The --watch feature depends on Node v0.6.0+. You are running " + process.version + ".");
|
||||
}
|
||||
if (opts.stdio) {
|
||||
return compileStdio();
|
||||
}
|
||||
if (opts["eval"]) {
|
||||
return forkNode;
|
||||
} else if (opts.help) {
|
||||
return usage;
|
||||
} else if (opts.version) {
|
||||
return version;
|
||||
} else if (opts.stdio) {
|
||||
return compileStdio;
|
||||
} else if (opts["eval"]) {
|
||||
return compileScript(null, sources[0]);
|
||||
}
|
||||
if (!sources.length) {
|
||||
} else if (opts.interactive) {
|
||||
return require('./repl').start();
|
||||
} else {
|
||||
return runScripts;
|
||||
}
|
||||
};
|
||||
|
||||
runScripts = function() {
|
||||
var literals, source, _i, _len, _results;
|
||||
literals = opts.run ? sources.splice(1) : [];
|
||||
process.argv = process.argv.slice(0, 2).concat(literals);
|
||||
process.argv[0] = 'coffee';
|
||||
@@ -476,6 +470,7 @@
|
||||
o.run = !(o.compile || o.print || o.lint || o.map);
|
||||
o.print = !!(o.print || (o["eval"] || o.stdio && o.compile));
|
||||
sources = o["arguments"];
|
||||
o.interactive || (o.interactive = sources.length === 0);
|
||||
for (i = _i = 0, _len = sources.length; _i < _len; i = ++_i) {
|
||||
source = sources[i];
|
||||
sourceCode[i] = null;
|
||||
|
||||
@@ -63,15 +63,17 @@ optionParser = null
|
||||
# `--` will be passed verbatim to your script as arguments in `process.argv`
|
||||
exports.run = ->
|
||||
parseOptions()
|
||||
return forkNode() if opts.nodejs
|
||||
return usage() if opts.help
|
||||
return version() if opts.version
|
||||
return require('./repl').start() if opts.interactive
|
||||
if opts.watch and !fs.watch
|
||||
return printWarn "The --watch feature depends on Node v0.6.0+. You are running #{process.version}."
|
||||
return compileStdio() if opts.stdio
|
||||
return compileScript null, sources[0] if opts.eval
|
||||
return require('./repl').start() unless sources.length
|
||||
if
|
||||
opts.nodejs then forkNode
|
||||
opts.help then usage
|
||||
opts.version then version
|
||||
opts.stdio then compileStdio
|
||||
opts.eval then compileScript null, sources[0]
|
||||
opts.interactive then require('./repl').start()
|
||||
else runScripts
|
||||
|
||||
# Run passed CoffeeScript files by evaluating them, in order.
|
||||
runScripts = ->
|
||||
literals = if opts.run then sources.splice 1 else []
|
||||
process.argv = process.argv[0..1].concat literals
|
||||
process.argv[0] = 'coffee'
|
||||
@@ -108,7 +110,6 @@ compilePath = (source, topLevel, base) ->
|
||||
notSources[source] = yes
|
||||
removeSource source, base
|
||||
|
||||
|
||||
# Compile a single source script, containing the given code, according to the
|
||||
# requested options. If evaluating the script directly sets `__filename`,
|
||||
# `__dirname` and `module.filename` to be correct relative to the script's path.
|
||||
@@ -318,6 +319,7 @@ parseOptions = ->
|
||||
o.run = not (o.compile or o.print or o.lint or o.map)
|
||||
o.print = !! (o.print or (o.eval or o.stdio and o.compile))
|
||||
sources = o.arguments
|
||||
o.interactive or= sources.length is 0
|
||||
sourceCode[i] = null for source, i in sources
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user