Skip to content

Commit ae7f97b

Browse files
2.0.0-beta4 (jashkenas#4628)
* 2.0.0-beta4 changelog * Recompile parser, update browser compiler * Updated annotated source and browser tests * Bump version to 2.0.0-beta4
1 parent 2653b3b commit ae7f97b

30 files changed

+4508
-1677
lines changed

docs/v2/annotated-source/coffeescript.html

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ <h1>coffeescript.coffee</h1>
315315
<div class="content"><div class='highlight'><pre> generateSourceMap = options.sourceMap <span class="hljs-keyword">or</span> options.inlineMap <span class="hljs-keyword">or</span> <span class="hljs-keyword">not</span> options.filename?
316316
filename = options.filename <span class="hljs-keyword">or</span> <span class="hljs-string">'&lt;anonymous&gt;'</span>
317317

318+
checkShebangLine filename, code
319+
318320
sources[filename] = code
319321
map = <span class="hljs-keyword">new</span> SourceMap <span class="hljs-keyword">if</span> generateSourceMap
320322

@@ -540,13 +542,11 @@ <h1>coffeescript.coffee</h1>
540542
@yylineno = @yylloc.first_line
541543
<span class="hljs-keyword">else</span>
542544
tag = <span class="hljs-string">''</span>
543-
544545
tag
545546
setInput: <span class="hljs-function"><span class="hljs-params">(tokens)</span> -&gt;</span>
546547
parser.tokens = tokens
547548
@pos = <span class="hljs-number">0</span>
548-
upcomingInput: <span class="hljs-function">-&gt;</span>
549-
<span class="hljs-string">""</span></pre></div></div>
549+
upcomingInput: <span class="hljs-function">-&gt;</span> <span class="hljs-string">''</span></pre></div></div>
550550

551551
</li>
552552

@@ -757,7 +757,20 @@ <h1>coffeescript.coffee</h1>
757757
<span class="hljs-keyword">break</span> <span class="hljs-keyword">if</span> frame.getFunction() <span class="hljs-keyword">is</span> exports.run
758758
<span class="hljs-string">" at <span class="hljs-subst">#{formatSourcePosition frame, getSourceMapping}</span>"</span>
759759

760-
<span class="hljs-string">"<span class="hljs-subst">#{err.toString()}</span>\n<span class="hljs-subst">#{frames.join <span class="hljs-string">'\n'</span>}</span>\n"</span></pre></div></div>
760+
<span class="hljs-string">"<span class="hljs-subst">#{err.toString()}</span>\n<span class="hljs-subst">#{frames.join <span class="hljs-string">'\n'</span>}</span>\n"</span>
761+
<span class="hljs-function">
762+
<span class="hljs-title">checkShebangLine</span> = <span class="hljs-params">(file, input)</span> -&gt;</span>
763+
firstLine = input.split(<span class="hljs-regexp">/$/m</span>)[<span class="hljs-number">0</span>]
764+
rest = firstLine?.match(<span class="hljs-regexp">/^#!\s*([^\s]+\s*)(.*)/</span>)
765+
args = rest?[<span class="hljs-number">2</span>]?.split(<span class="hljs-regexp">/\s/</span>).filter (s) -&gt; s <span class="hljs-keyword">isnt</span> <span class="hljs-string">''</span>
766+
<span class="hljs-keyword">if</span> args?.length &gt; <span class="hljs-number">1</span>
767+
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
768+
The script to be run begins with a shebang line with more than one
769+
argument. This script will fail on platforms such as Linux which only
770+
allow a single argument.
771+
'''</span>
772+
<span class="hljs-built_in">console</span>.error <span class="hljs-string">"The shebang line was: '<span class="hljs-subst">#{firstLine}</span>' in file '<span class="hljs-subst">#{file}</span>'"</span>
773+
<span class="hljs-built_in">console</span>.error <span class="hljs-string">"The arguments were: <span class="hljs-subst">#{JSON.stringify args}</span>"</span></pre></div></div>
761774

762775
</li>
763776

docs/v2/annotated-source/command.html

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ <h1>command.coffee</h1>
180180
</div>
181181

182182
<div class="content"><div class='highlight'><pre>BANNER = <span class="hljs-string">'''
183-
Usage: coffee [options] path/to/script.coffee -- [args]
183+
Usage: coffee [options] path/to/script.coffee [args]
184184

185185
If called without options, `coffee` will run your script.
186186
'''</span></pre></div></div>
@@ -260,7 +260,21 @@ <h1>command.coffee</h1>
260260

261261
<div class="content"><div class='highlight'><pre>exports.run = <span class="hljs-function">-&gt;</span>
262262
optionParser = buildCSOptionParser()
263-
parseOptions()</pre></div></div>
263+
<span class="hljs-keyword">try</span> parseOptions()
264+
<span class="hljs-keyword">catch</span> err
265+
<span class="hljs-built_in">console</span>.error <span class="hljs-string">"option parsing error: <span class="hljs-subst">#{err.message}</span>"</span>
266+
process.exit <span class="hljs-number">1</span>
267+
268+
<span class="hljs-keyword">if</span> (<span class="hljs-keyword">not</span> opts.doubleDashed) <span class="hljs-keyword">and</span> (opts.arguments[<span class="hljs-number">1</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'--'</span>)
269+
printWarn <span class="hljs-string">'''
270+
coffee was invoked with '--' as the second positional argument, which is
271+
now deprecated. To pass '--' as an argument to a script to run, put an
272+
additional '--' before the path to your script.
273+
274+
'--' will be removed from the argument list.
275+
'''</span>
276+
printWarn <span class="hljs-string">"The positional arguments were: <span class="hljs-subst">#{JSON.stringify opts.arguments}</span>"</span>
277+
opts.arguments = [opts.arguments[<span class="hljs-number">0</span>]].concat opts.arguments[<span class="hljs-number">2.</span>.]</pre></div></div>
264278

265279
</li>
266280

@@ -842,6 +856,9 @@ <h1>command.coffee</h1>
842856
cwd: process.cwd()
843857
env: process.env
844858
stdio: [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>]
859+
<span class="hljs-keyword">for</span> signal <span class="hljs-keyword">in</span> [<span class="hljs-string">'SIGINT'</span>, <span class="hljs-string">'SIGTERM'</span>]
860+
process.<span class="hljs-literal">on</span> signal, <span class="hljs-keyword">do</span> (signal) -&gt;
861+
-&gt; p.kill signal
845862
p.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>, <span class="hljs-function"><span class="hljs-params">(code)</span> -&gt;</span> process.exit code</pre></div></div>
846863

847864
</li>

0 commit comments

Comments
 (0)