mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-19 03:44:23 -05:00
separating out the --no-wrap and the --globals arguments, which shouldn't be jammed together
This commit is contained in:
@@ -29,7 +29,7 @@ exports.run: args =>
|
||||
while true
|
||||
try
|
||||
system.stdout.write('coffee> ').flush()
|
||||
result: exports.evalCS(Readline.readline())
|
||||
result: exports.evalCS(Readline.readline(), ['--globals'])
|
||||
print(result) if result isnt undefined
|
||||
catch e
|
||||
print(e)
|
||||
@@ -41,15 +41,15 @@ exports.compileFile: path =>
|
||||
coffee.stdout.read()
|
||||
|
||||
# Compile a string of CoffeeScript into JavaScript.
|
||||
exports.compile: source =>
|
||||
coffee: OS.popen([coffeePath, "--eval", "--no-wrap"])
|
||||
exports.compile: source, flags =>
|
||||
coffee: OS.popen([coffeePath, "--eval", "--no-wrap"].concat(flags or []))
|
||||
coffee.stdin.write(source).flush().close()
|
||||
checkForErrors(coffee)
|
||||
coffee.stdout.read()
|
||||
|
||||
# Evaluating a string of CoffeeScript first compiles it externally.
|
||||
exports.evalCS: source =>
|
||||
eval(exports.compile(source))
|
||||
exports.evalCS: source, flags =>
|
||||
eval(exports.compile(source, flags))
|
||||
|
||||
# Make a factory for the CoffeeScript environment.
|
||||
exports.makeNarwhalFactory: path =>
|
||||
|
||||
@@ -20,25 +20,24 @@
|
||||
// Run a simple REPL, round-tripping to the CoffeeScript compiler for every
|
||||
// command.
|
||||
exports.run = function run(args) {
|
||||
var __a, __b, __c, i, path, result;
|
||||
var __a, __b, i, result;
|
||||
if (args.length) {
|
||||
__a = args;
|
||||
__b = [];
|
||||
for (i in __a) {
|
||||
if (__a.hasOwnProperty(i)) {
|
||||
path = __a[i];
|
||||
exports.evalCS(File.read(path));
|
||||
__c = delete args[i];
|
||||
__b.push(__c);
|
||||
}
|
||||
__b = function(path, i) {
|
||||
exports.evalCS(File.read(path));
|
||||
delete args[i];
|
||||
};
|
||||
if (__a instanceof Array) {
|
||||
for (i=0; i<__a.length; i++) __b(__a[i], i);
|
||||
} else {
|
||||
for (i in __a) { if (__a.hasOwnProperty(i)) __b(__a[i], i); }
|
||||
}
|
||||
__b;
|
||||
return true;
|
||||
}
|
||||
while (true) {
|
||||
try {
|
||||
system.stdout.write('coffee> ').flush();
|
||||
result = exports.evalCS(Readline.readline());
|
||||
result = exports.evalCS(Readline.readline(), ['--globals']);
|
||||
if (result !== undefined) {
|
||||
print(result);
|
||||
}
|
||||
@@ -46,6 +45,7 @@
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
// Compile a given CoffeeScript file into JavaScript.
|
||||
exports.compileFile = function compileFile(path) {
|
||||
@@ -55,16 +55,16 @@
|
||||
return coffee.stdout.read();
|
||||
};
|
||||
// Compile a string of CoffeeScript into JavaScript.
|
||||
exports.compile = function compile(source) {
|
||||
exports.compile = function compile(source, flags) {
|
||||
var coffee;
|
||||
coffee = OS.popen([coffeePath, "--eval", "--no-wrap"]);
|
||||
coffee = OS.popen([coffeePath, "--eval", "--no-wrap"].concat(flags || []));
|
||||
coffee.stdin.write(source).flush().close();
|
||||
checkForErrors(coffee);
|
||||
return coffee.stdout.read();
|
||||
};
|
||||
// Evaluating a string of CoffeeScript first compiles it externally.
|
||||
exports.evalCS = function evalCS(source) {
|
||||
return eval(exports.compile(source));
|
||||
exports.evalCS = function evalCS(source, flags) {
|
||||
return eval(exports.compile(source, flags));
|
||||
};
|
||||
// Make a factory for the CoffeeScript environment.
|
||||
exports.makeNarwhalFactory = function makeNarwhalFactory(path) {
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
// Reload the coffee-script environment from source.
|
||||
reload: function reload(topId, path) {
|
||||
coffeescript = coffeescript || require('coffee-script');
|
||||
return (factories[topId] = function() {
|
||||
return factories[topId] = function() {
|
||||
return coffeescript.makeNarwhalFactory(path);
|
||||
});
|
||||
};
|
||||
},
|
||||
// Ensure that the coffee-script environment is loaded.
|
||||
load: function load(topId, path) {
|
||||
|
||||
Reference in New Issue
Block a user