Skip to content

Commit

Permalink
changed bin/coffee-script to bin/coffee
Browse files Browse the repository at this point in the history
  • Loading branch information
jashkenas committed Dec 26, 2009
1 parent 6a30d48 commit 3c67d54
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 39 deletions.
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
gem install coffee-script

Compile a script:
coffee-script /path/to/script.coffee
coffee /path/to/script.coffee

For documentation, usage, and examples, see:
http://jashkenas.github.com/coffee-script/
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ namespace :build do

desc "Compile the Narwhal interface for --interactive and --run"
task :narwhal do
sh "bin/coffee-script lib/coffee_script/narwhal/*.coffee -o lib/coffee_script/narwhal/js"
sh "bin/coffee lib/coffee_script/narwhal/*.coffee -o lib/coffee_script/narwhal/js"
end

end

desc "Build the documentation page"
task :doc do
source = 'documentation/index.html.erb'
child = fork { exec "bin/coffee-script documentation/coffee/*.coffee -o documentation/js -w" }
child = fork { exec "bin/coffee documentation/coffee/*.coffee -o documentation/js -w" }
at_exit { Process.kill("INT", child) }
Signal.trap("INT") { exit }
loop do
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion coffee-script.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |s|
s.has_rdoc = false

s.require_paths = ['lib']
s.executables = ['coffee-script']
s.executables = ['coffee']

s.files = Dir['bin/*', 'examples/*', 'lib/**/*', 'coffee-script.gemspec', 'LICENSE', 'README']
end
18 changes: 9 additions & 9 deletions documentation/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@
gem install coffee-script</pre>

<p>
Installing the gem provides the <tt>coffee-script</tt> command, which can
Installing the gem provides the <tt>coffee</tt> command, which can
be used to compile CoffeeScript <tt>.coffee</tt> files into JavaScript, as
well as debug them. In conjunction with
<a href="http://narwhaljs.org/">Narwhal</a>, the <tt>coffee-script</tt>
<a href="http://narwhaljs.org/">Narwhal</a>, the <tt>coffee</tt>
command also provides direct evaluation and an interactive REPL.
When compiling to JavaScript, <tt>coffee-script</tt> writes the output
When compiling to JavaScript, <tt>coffee</tt> writes the output
as <tt>.js</tt> files in the same directory by default, but output
can be customized with the following options:
</p>
Expand Down Expand Up @@ -148,7 +148,7 @@ gem install coffee-script</pre>
<td><code>-e, --eval</code></td>
<td>
Compile and print a little snippet of CoffeeScript directly from the
command line (or from <b>stdin</b>). For example:<br /><tt>coffee-script -e "square: x => x * x."</tt>
command line (or from <b>stdin</b>). For example:<br /><tt>coffee -e "square: x => x * x."</tt>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -187,10 +187,10 @@ gem install coffee-script</pre>
</p>

<pre>
coffee-script path/to/script.coffee
coffee-script --interactive
coffee-script --watch --lint experimental.coffee
coffee-script --print app/scripts/*.coffee > concatenation.js</pre>
coffee path/to/script.coffee
coffee --interactive
coffee --watch --lint experimental.coffee
coffee --print app/scripts/*.coffee > concatenation.js</pre>

<h2>Language Reference</h2>

Expand Down Expand Up @@ -470,7 +470,7 @@ coffee-script --print app/scripts/*.coffee > concatenation.js</pre>

<p>
<b class="header" style="margin-top: 20px;">0.1.3</b>
The <tt>coffee-script</tt> command now includes <tt>--interactive</tt>,
The <tt>coffee</tt> command now includes <tt>--interactive</tt>,
which launches an interactive CoffeeScript session, and <tt>--run</tt>,
which directly compiles and executes a script. Both options depend on a
working installation of Narwhal.
Expand Down
8 changes: 7 additions & 1 deletion documentation/js/array_comprehensions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(function(){
var __a, __b, __c, __d, __e, __f, __g, __h, food, i, lunch, row;
var __a, __b, __c, __d, __e, __f, __g, __h, __i, __j, __k, __l, food, i, lunch, row;
// Eat lunch.
__a = ['toast', 'cheese', 'wine'];
__d = [];
Expand All @@ -17,4 +17,10 @@
__h[__f] = i % 2 === 0 ? highlight(row) : null;
}
__h;
// Check the first one hundred combinations.
__k = [];
for (__l=0, i=1, __j=100; i<=__j; i++, __l++) {
__k[__l] = lockpick(combinations[i]);
}
__k;
})();
29 changes: 19 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ <h2 id="installation">Installation and Usage</h2>
gem install coffee-script</pre>

<p>
Installing the gem provides the <tt>coffee-script</tt> command, which can
Installing the gem provides the <tt>coffee</tt> command, which can
be used to compile CoffeeScript <tt>.coffee</tt> files into JavaScript, as
well as debug them. In conjunction with
<a href="http://narwhaljs.org/">Narwhal</a>, the <tt>coffee-script</tt>
<a href="http://narwhaljs.org/">Narwhal</a>, the <tt>coffee</tt>
command also provides direct evaluation and an interactive REPL.
When compiling to JavaScript, <tt>coffee-script</tt> writes the output
When compiling to JavaScript, <tt>coffee</tt> writes the output
as <tt>.js</tt> files in the same directory by default, but output
can be customized with the following options:
</p>
Expand Down Expand Up @@ -216,7 +216,7 @@ <h2 id="installation">Installation and Usage</h2>
<td><code>-e, --eval</code></td>
<td>
Compile and print a little snippet of CoffeeScript directly from the
command line (or from <b>stdin</b>). For example:<br /><tt>coffee-script -e "square: x => x * x."</tt>
command line (or from <b>stdin</b>). For example:<br /><tt>coffee -e "square: x => x * x."</tt>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -255,10 +255,10 @@ <h2 id="installation">Installation and Usage</h2>
</p>

<pre>
coffee-script path/to/script.coffee
coffee-script --interactive
coffee-script --watch --lint experimental.coffee
coffee-script --print app/scripts/*.coffee > concatenation.js</pre>
coffee path/to/script.coffee
coffee --interactive
coffee --watch --lint experimental.coffee
coffee --print app/scripts/*.coffee > concatenation.js</pre>

<h2>Language Reference</h2>

Expand Down Expand Up @@ -580,7 +580,10 @@ <h2>Language Reference</h2>

<span class="Comment"><span class="Comment">#</span> Zebra-stripe a table.</span>
highlight(row) <span class="Keyword">for</span> row, i <span class="Keyword">in</span> table <span class="Keyword">if</span> i <span class="Keyword">%</span> <span class="Number">2</span> <span class="Keyword">is</span> <span class="Number">0</span>.
</pre><pre class="idle"><span class="Storage">var</span> __a, __b, __c, __d, __e, __f, __g, __h, food, i, lunch, row;

<span class="Comment"><span class="Comment">#</span> Check the first one hundred combinations.</span>
lockpick(combinations[i]) <span class="Keyword">for</span> i <span class="Keyword">in</span> [<span class="Number">1</span>..<span class="Number">100</span>].
</pre><pre class="idle"><span class="Storage">var</span> __a, __b, __c, __d, __e, __f, __g, __h, __i, __j, __k, __l, food, i, lunch, row;
<span class="Comment"><span class="Comment">//</span> Eat lunch.</span>
__a <span class="Keyword">=</span> [<span class="String"><span class="String">'</span>toast<span class="String">'</span></span>, <span class="String"><span class="String">'</span>cheese<span class="String">'</span></span>, <span class="String"><span class="String">'</span>wine<span class="String">'</span></span>];
__d <span class="Keyword">=</span> [];
Expand All @@ -598,6 +601,12 @@ <h2>Language Reference</h2>
__h[__f] <span class="Keyword">=</span> i <span class="Keyword">%</span> <span class="Number">2</span> <span class="Keyword">===</span> <span class="Number">0</span> ? highlight(row) : <span class="BuiltInConstant">null</span>;
}
__h;
<span class="Comment"><span class="Comment">//</span> Check the first one hundred combinations.</span>
__k <span class="Keyword">=</span> [];
<span class="Keyword">for</span> (__l<span class="Keyword">=</span><span class="Number">0</span>, i<span class="Keyword">=</span><span class="Number">1</span>, __j<span class="Keyword">=</span><span class="Number">100</span>; i<span class="Keyword">&lt;=</span>__j; i<span class="Keyword">++</span>, __l<span class="Keyword">++</span>) {
__k[__l] <span class="Keyword">=</span> lockpick(combinations[i]);
}
__k;
</pre><br class='clear' /></div>

<p id="slice">
Expand Down Expand Up @@ -889,7 +898,7 @@ <h2 id="change_log">Change Log</h2>

<p>
<b class="header" style="margin-top: 20px;">0.1.3</b>
The <tt>coffee-script</tt> command now includes <tt>--interactive</tt>,
The <tt>coffee</tt> command now includes <tt>--interactive</tt>,
which launches an interactive CoffeeScript session, and <tt>--run</tt>,
which directly compiles and executes a script. Both options depend on a
working installation of Narwhal.
Expand Down
10 changes: 5 additions & 5 deletions lib/coffee_script/command_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

module CoffeeScript

# The CommandLine handles all of the functionality of the `coffee-script`
# The CommandLine handles all of the functionality of the `coffee`
# utility.
class CommandLine

BANNER = <<-EOS
coffee-script compiles CoffeeScript source files into JavaScript.
coffee compiles CoffeeScript source files into JavaScript.
Usage:
coffee-script path/to/script.coffee
coffee path/to/script.coffee
EOS

# Seconds to pause between checks for changed source files.
Expand Down Expand Up @@ -190,8 +190,8 @@ def parse_options
install_bundle
exit
end
opts.on_tail('--version', 'display coffee-script version') do
puts "coffee-script version #{CoffeeScript::VERSION}"
opts.on_tail('--version', 'display CoffeeScript version') do
puts "CoffeeScript version #{CoffeeScript::VERSION}"
exit
end
opts.on_tail('-h', '--help', 'display this help message') do
Expand Down
6 changes: 3 additions & 3 deletions lib/coffee_script/narwhal/coffee-script.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This (javascript) file is generated from lib/coffee_script/narwhal/coffee-script.coffee

# Executes the `coffee-script` Ruby program to convert from CoffeeScript
# Executes the `coffee` Ruby program to convert from CoffeeScript
# to Javascript. Eventually this will hopefully happen entirely within JS.

# Require external dependencies.
Expand All @@ -9,13 +9,13 @@ File: require('file')
Readline: require('readline')

# The path to the CoffeeScript Compiler.
coffeePath: File.path(module.path).dirname().dirname().dirname().dirname().dirname().join('bin', 'coffee-script')
coffeePath: File.path(module.path).dirname().dirname().dirname().dirname().dirname().join('bin', 'coffee')

# Our general-purpose error handler.
checkForErrors: coffeeProcess =>
return true if coffeeProcess.wait() is 0
system.stderr.print(coffeeProcess.stderr.read())
throw new Error("coffee-script compile error").
throw new Error("CoffeeScript compile error").

# Run a simple REPL, round-tripping to the CoffeeScript compiler for every
# command.
Expand Down
6 changes: 3 additions & 3 deletions lib/coffee_script/narwhal/js/coffee-script.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
(function(){
var File, OS, Readline, checkForErrors, coffeePath;
// This (javascript) file is generated from lib/coffee_script/narwhal/coffee-script.coffee Executes the `coffee-script` Ruby program to convert from CoffeeScript
// This (javascript) file is generated from lib/coffee_script/narwhal/coffee-script.coffee Executes the `coffee` Ruby program to convert from CoffeeScript
// to Javascript. Eventually this will hopefully happen entirely within JS. Require external dependencies.
OS = require('os');
File = require('file');
Readline = require('readline');
// The path to the CoffeeScript Compiler.
coffeePath = File.path(module.path).dirname().dirname().dirname().dirname().dirname().join('bin', 'coffee-script');
coffeePath = File.path(module.path).dirname().dirname().dirname().dirname().dirname().join('bin', 'coffee');
// Our general-purpose error handler.
checkForErrors = function(coffeeProcess) {
if (coffeeProcess.wait() === 0) {
return true;
}
system.stderr.print(coffeeProcess.stderr.read());
throw new Error("coffee-script compile error");
throw new Error("CoffeeScript compile error");
};
// Run a simple REPL, round-tripping to the CoffeeScript compiler for every
// command.
Expand Down
7 changes: 7 additions & 0 deletions lib/coffee_script/nodes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,13 @@ def exclusive?
@exclusive
end

# TODO -- figure out if we can detect if a range runs negative.
def downward?

end

# TODO -- figure out if we can expand ranges into the corresponding array,
# as an expression, reliably.
def compile(o={})
write()
end
Expand Down
8 changes: 4 additions & 4 deletions test/unit/test_execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ class ExecutionTest < Test::Unit::TestCase

def test_execution_of_coffeescript
sources = ['test/fixtures/execution/*.coffee'].join(' ')
assert `bin/coffee-script -r #{sources}`.match(ALLS_WELL)
assert `bin/coffee -r #{sources}`.match(ALLS_WELL)
end

def test_lintless_coffeescript
lint_results = `bin/coffee-script -l test/fixtures/execution/*.coffee`
lint_results = `bin/coffee -l test/fixtures/execution/*.coffee`
assert lint_results.match(NO_WARNINGS)
end

def test_lintless_examples
lint_results = `bin/coffee-script -l examples/*.coffee`
lint_results = `bin/coffee -l examples/*.coffee`
assert lint_results.match(NO_WARNINGS)
end

def test_lintless_documentation
lint_results = `bin/coffee-script -l documentation/coffee/*.coffee`
lint_results = `bin/coffee -l documentation/coffee/*.coffee`
assert lint_results.match(NO_WARNINGS)
end

Expand Down

0 comments on commit 3c67d54

Please sign in to comment.