1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

Fixed Narwhal integration. Cleaned up module organization, etc.

This commit is contained in:
tlrobinson 2009-12-28 01:16:57 -08:00
parent ac00a19514
commit 55616cf3b8
9 changed files with 12 additions and 15 deletions

View file

@ -19,7 +19,8 @@ namespace :build do
desc "Compile the Narwhal interface for --interactive and --run"
task :narwhal do
sh "bin/coffee lib/coffee_script/narwhal/*.coffee -o lib/coffee_script/narwhal/js"
sh "bin/coffee lib/coffee_script/narwhal/*.coffee -o lib/coffee_script/narwhal/lib/coffee-script"
sh "mv lib/coffee_script/narwhal/lib/coffee-script/coffee-script.js lib/coffee_script/narwhal/lib/coffee-script.js"
end
end

View file

@ -19,8 +19,8 @@ Usage:
# Seconds to pause between checks for changed source files.
WATCH_INTERVAL = 0.5
# Path to the Narwhal Launcher:
LAUNCHER = File.expand_path(File.dirname(__FILE__)) + '/narwhal/js/launcher.js'
# Command to execute in Narwhal
LAUNCHER = "narwhal -e 'require(\"coffee-script\").run(system.args);'"
# Run the CommandLine off the contents of ARGV.
def initialize
@ -107,7 +107,7 @@ Usage:
# Use Narwhal to run an interactive CoffeeScript session.
def launch_repl
exec "narwhal #{LAUNCHER}"
exec "#{LAUNCHER}"
rescue Errno::ENOENT
puts "Error: Narwhal must be installed to use the interactive REPL."
exit(1)
@ -116,7 +116,7 @@ Usage:
# Use Narwhal to compile and execute CoffeeScripts.
def run_scripts
sources = @sources.join(' ')
exec "narwhal #{LAUNCHER} #{sources}"
exec "#{LAUNCHER} #{sources}"
rescue Errno::ENOENT
puts "Error: Narwhal must be installed in order to execute CoffeeScripts."
exit(1)

View file

@ -53,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){ 1 + 1 /**/\n}"
factoryText: "function(require,exports,module,system,print){ "+code+" /**/\n}"
if system.engine is "rhino"
Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(global, factoryText, path, 0, null)
else

View file

@ -1,3 +0,0 @@
(function(){
require("./coffee-script").run(system.args);
})();

View file

@ -1 +0,0 @@
require("./coffee-script").run(system.args)

View file

@ -65,7 +65,7 @@
exports.makeNarwhalFactory = function(path) {
var code, factoryText;
code = exports.compileFile(path);
factoryText = "function(require,exports,module,system,print){ 1 + 1 /**/\n}";
factoryText = "function(require,exports,module,system,print){ " + code + " /**/\n}";
if (system.engine === "rhino") {
return Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(global, factoryText, path, 0, null);
} else {

View file

@ -7,7 +7,7 @@
loader = {
// Reload the coffee-script environment from source.
reload: function(topId, path) {
coffeescript = coffeescript || require('./coffee-script');
coffeescript = coffeescript || require('coffee-script');
return (factories[topId] = coffeescript.makeNarwhalFactory(path));
},
// Ensure that the coffee-script environment is loaded.

View file

@ -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.

View file

@ -1,7 +1,7 @@
{
"name": "coffee-script",
"lib": "lib/coffee_script/narwhal/js",
"preload": ["loader"],
"lib": "lib/coffee_script/narwhal/lib",
"preload": ["coffee-script/loader"],
"description": "Unfancy JavaScript",
"keywords": ["javascript", "language"],
"author": "Jeremy Ashkenas",