fixing paths for running
coffee compiles CoffeeScript source files into JavaScript. Usage: coffee path/to/script.coffee -i, --interactive run a CoffeeScript REPL (requires Narwhal) -r, --run compile and run a script (requires Narwhal) -o, --output [DIR] set the directory for compiled JavaScript -w, --watch watch scripts for changes, and recompile -p, --print print the compiled JavaScript to stdout -l, --lint pipe the compiled JavaScript through JSLint -e, --eval compile a cli scriptlet or read from stdin -t, --tokens print the tokens that the lexer produces -v, --verbose print at every step of code generation -n, --no-wrap raw output, no safety wrapper or vars --install-bundle install the CoffeeScript TextMate bundle --version display CoffeeScript version -h, --help display this help message outside of the coffee-script directory
This commit is contained in:
parent
55e736cb27
commit
7ae8687a3e
|
@ -19,6 +19,9 @@ Usage:
|
||||||
# Seconds to pause between checks for changed source files.
|
# Seconds to pause between checks for changed source files.
|
||||||
WATCH_INTERVAL = 0.5
|
WATCH_INTERVAL = 0.5
|
||||||
|
|
||||||
|
# Path to the Narwhal Launcher:
|
||||||
|
LAUNCHER = File.expand_path(File.dirname(__FILE__)) + '/narwhal/js/launcher.js'
|
||||||
|
|
||||||
# Run the CommandLine off the contents of ARGV.
|
# Run the CommandLine off the contents of ARGV.
|
||||||
def initialize
|
def initialize
|
||||||
@mtimes = {}
|
@mtimes = {}
|
||||||
|
@ -104,7 +107,7 @@ Usage:
|
||||||
|
|
||||||
# Use Narwhal to run an interactive CoffeeScript session.
|
# Use Narwhal to run an interactive CoffeeScript session.
|
||||||
def launch_repl
|
def launch_repl
|
||||||
exec "narwhal lib/coffee_script/narwhal/js/launcher.js"
|
exec "narwhal #{LAUNCHER}"
|
||||||
rescue Errno::ENOENT
|
rescue Errno::ENOENT
|
||||||
puts "Error: Narwhal must be installed to use the interactive REPL."
|
puts "Error: Narwhal must be installed to use the interactive REPL."
|
||||||
exit(1)
|
exit(1)
|
||||||
|
@ -113,7 +116,7 @@ Usage:
|
||||||
# Use Narwhal to compile and execute CoffeeScripts.
|
# Use Narwhal to compile and execute CoffeeScripts.
|
||||||
def run_scripts
|
def run_scripts
|
||||||
sources = @sources.join(' ')
|
sources = @sources.join(' ')
|
||||||
exec "narwhal lib/coffee_script/narwhal/js/launcher.js #{sources}"
|
exec "narwhal #{LAUNCHER} #{sources}"
|
||||||
rescue Errno::ENOENT
|
rescue Errno::ENOENT
|
||||||
puts "Error: Narwhal must be installed in order to execute CoffeeScripts."
|
puts "Error: Narwhal must be installed in order to execute CoffeeScripts."
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
|
@ -21,7 +21,9 @@ checkForErrors: coffeeProcess =>
|
||||||
# command.
|
# command.
|
||||||
exports.run: args =>
|
exports.run: args =>
|
||||||
args.shift()
|
args.shift()
|
||||||
return require(File.absolute(args[0])) if args.length
|
if args.length
|
||||||
|
exports.evalCS(File.read(path)) for path in args.
|
||||||
|
return true.
|
||||||
|
|
||||||
while true
|
while true
|
||||||
try
|
try
|
||||||
|
@ -51,7 +53,7 @@ exports.evalCS: source =>
|
||||||
# Make a factory for the CoffeeScript environment.
|
# Make a factory for the CoffeeScript environment.
|
||||||
exports.makeNarwhalFactory: path =>
|
exports.makeNarwhalFactory: path =>
|
||||||
code: exports.compileFile(path)
|
code: exports.compileFile(path)
|
||||||
factoryText: "function(require,exports,module,system,print){" + code + "/**/\n}"
|
factoryText: "function(require,exports,module,system,print){ 1 + 1 /**/\n}"
|
||||||
if system.engine is "rhino"
|
if system.engine is "rhino"
|
||||||
Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(global, factoryText, path, 0, null)
|
Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(global, factoryText, path, 0, null)
|
||||||
else
|
else
|
||||||
|
|
|
@ -18,10 +18,17 @@
|
||||||
// Run a simple REPL, round-tripping to the CoffeeScript compiler for every
|
// Run a simple REPL, round-tripping to the CoffeeScript compiler for every
|
||||||
// command.
|
// command.
|
||||||
exports.run = function(args) {
|
exports.run = function(args) {
|
||||||
var result;
|
var __a, __b, __c, __d, path, result;
|
||||||
args.shift();
|
args.shift();
|
||||||
if (args.length) {
|
if (args.length) {
|
||||||
return require(File.absolute(args[0]));
|
__a = args;
|
||||||
|
__d = [];
|
||||||
|
for (__b=0, __c=__a.length; __b<__c; __b++) {
|
||||||
|
path = __a[__b];
|
||||||
|
__d[__b] = exports.evalCS(File.read(path));
|
||||||
|
}
|
||||||
|
__d;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
|
@ -58,7 +65,7 @@
|
||||||
exports.makeNarwhalFactory = function(path) {
|
exports.makeNarwhalFactory = function(path) {
|
||||||
var code, factoryText;
|
var code, factoryText;
|
||||||
code = exports.compileFile(path);
|
code = exports.compileFile(path);
|
||||||
factoryText = "function(require,exports,module,system,print){" + code + "/**/\n}";
|
factoryText = "function(require,exports,module,system,print){ 1 + 1 /**/\n}";
|
||||||
if (system.engine === "rhino") {
|
if (system.engine === "rhino") {
|
||||||
return Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(global, factoryText, path, 0, null);
|
return Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(global, factoryText, path, 0, null);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
(function(){
|
(function(){
|
||||||
require("coffee-script").run(system.args);
|
require("./coffee-script").run(system.args);
|
||||||
})();
|
})();
|
|
@ -7,9 +7,8 @@
|
||||||
loader = {
|
loader = {
|
||||||
// Reload the coffee-script environment from source.
|
// Reload the coffee-script environment from source.
|
||||||
reload: function(topId, path) {
|
reload: function(topId, path) {
|
||||||
coffeescript = coffeescript || require('coffee-script');
|
coffeescript = coffeescript || require('./coffee-script');
|
||||||
factories[topId] = coffeescript.makeNarwhalFactory(path);
|
return (factories[topId] = coffeescript.makeNarwhalFactory(path));
|
||||||
return factories[topId];
|
|
||||||
},
|
},
|
||||||
// Ensure that the coffee-script environment is loaded.
|
// Ensure that the coffee-script environment is loaded.
|
||||||
load: function(topId, path) {
|
load: function(topId, path) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
require("coffee-script").run(system.args)
|
require("./coffee-script").run(system.args)
|
|
@ -7,7 +7,7 @@ loader: {
|
||||||
|
|
||||||
# Reload the coffee-script environment from source.
|
# Reload the coffee-script environment from source.
|
||||||
reload: topId, path =>
|
reload: topId, path =>
|
||||||
coffeescript ||= require('coffee-script')
|
coffeescript ||= require('./coffee-script')
|
||||||
factories[topId]: coffeescript.makeNarwhalFactory(path).
|
factories[topId]: coffeescript.makeNarwhalFactory(path).
|
||||||
|
|
||||||
# Ensure that the coffee-script environment is loaded.
|
# Ensure that the coffee-script environment is loaded.
|
||||||
|
|
Loading…
Reference in New Issue