mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-17 19:11:22 -05:00
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:
@@ -21,7 +21,9 @@ checkForErrors: coffeeProcess =>
|
||||
# command.
|
||||
exports.run: args =>
|
||||
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
|
||||
try
|
||||
@@ -51,7 +53,7 @@ exports.evalCS: source =>
|
||||
# Make a factory for the CoffeeScript environment.
|
||||
exports.makeNarwhalFactory: 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"
|
||||
Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(global, factoryText, path, 0, null)
|
||||
else
|
||||
|
||||
@@ -18,10 +18,17 @@
|
||||
// Run a simple REPL, round-tripping to the CoffeeScript compiler for every
|
||||
// command.
|
||||
exports.run = function(args) {
|
||||
var result;
|
||||
var __a, __b, __c, __d, path, result;
|
||||
args.shift();
|
||||
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) {
|
||||
try {
|
||||
@@ -58,7 +65,7 @@
|
||||
exports.makeNarwhalFactory = function(path) {
|
||||
var code, factoryText;
|
||||
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") {
|
||||
return Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(global, factoryText, path, 0, null);
|
||||
} else {
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
(function(){
|
||||
require("coffee-script").run(system.args);
|
||||
require("./coffee-script").run(system.args);
|
||||
})();
|
||||
@@ -7,9 +7,8 @@
|
||||
loader = {
|
||||
// Reload the coffee-script environment from source.
|
||||
reload: function(topId, path) {
|
||||
coffeescript = coffeescript || require('coffee-script');
|
||||
factories[topId] = coffeescript.makeNarwhalFactory(path);
|
||||
return factories[topId];
|
||||
coffeescript = coffeescript || require('./coffee-script');
|
||||
return (factories[topId] = coffeescript.makeNarwhalFactory(path));
|
||||
},
|
||||
// Ensure that the coffee-script environment is loaded.
|
||||
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: topId, path =>
|
||||
coffeescript ||= require('coffee-script')
|
||||
coffeescript ||= require('./coffee-script')
|
||||
factories[topId]: coffeescript.makeNarwhalFactory(path).
|
||||
|
||||
# Ensure that the coffee-script environment is loaded.
|
||||
|
||||
Reference in New Issue
Block a user