light refactors + tweaks
This commit is contained in:
parent
8d30feaf88
commit
bb05e07e4e
6
Cakefile
6
Cakefile
|
@ -1,7 +1,7 @@
|
|||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
CoffeeScript = require './lib/coffee-script'
|
||||
{spawn, exec} = require 'child_process'
|
||||
path = require 'path'
|
||||
|
||||
# ANSI Terminal Colors.
|
||||
red = '\033[0;31m'
|
||||
|
@ -97,12 +97,10 @@ task 'loc', 'count the lines of source code in the CoffeeScript compiler', ->
|
|||
runTests = (CoffeeScript) ->
|
||||
startTime = Date.now()
|
||||
passedTests = failedTests = 0
|
||||
wrap = (name, func) ->
|
||||
for all name, func of require 'assert'
|
||||
global[name] = ->
|
||||
passedTests += 1
|
||||
func arguments...
|
||||
for all name, func of require 'assert'
|
||||
wrap name, func
|
||||
global.eq = global.strictEqual
|
||||
global.CoffeeScript = CoffeeScript
|
||||
process.on 'exit', ->
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
if (options.fileName) {
|
||||
err.message = "In " + options.fileName + ", " + err.message;
|
||||
}
|
||||
console.error(err.toString());
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
@ -44,13 +45,13 @@
|
|||
if (root.moduleCache) {
|
||||
root.moduleCache = {};
|
||||
}
|
||||
return path.extname(root.filename) !== '.coffee' || require.extensions ? root._compile(exports.compile(code, options), root.filename) : root._compile(code, root.filename);
|
||||
return path.extname(root.filename) !== '.coffee' || require.extensions ? root._compile(compile(code, options), root.filename) : root._compile(code, root.filename);
|
||||
};
|
||||
exports.eval = function(code, options) {
|
||||
var __dirname, __filename;
|
||||
__filename = options.fileName;
|
||||
__dirname = path.dirname(__filename);
|
||||
return eval(exports.compile(code, options));
|
||||
return eval(compile(code, options));
|
||||
};
|
||||
lexer = new Lexer;
|
||||
parser.lexer = {
|
||||
|
|
|
@ -35,6 +35,8 @@ runScripts = ->
|
|||
else
|
||||
CoffeeScript.run script.innerHTML
|
||||
null
|
||||
|
||||
# Listen for window load, both in browsers and in IE.
|
||||
if window.addEventListener
|
||||
addEventListener 'DOMContentLoaded', runScripts, no
|
||||
else
|
||||
|
|
|
@ -11,7 +11,7 @@ path = require 'path'
|
|||
{Lexer} = require './lexer'
|
||||
{parser} = require './parser'
|
||||
|
||||
# TODO: Remove registerExtension when fully deprecated
|
||||
# TODO: Remove registerExtension when fully deprecated.
|
||||
if require.extensions
|
||||
require.extensions['.coffee'] = (module, filename) ->
|
||||
content = compile fs.readFileSync filename, 'utf8'
|
||||
|
@ -51,13 +51,13 @@ exports.run = (code, options) ->
|
|||
root = module
|
||||
while root.parent
|
||||
root = root.parent
|
||||
# Set the filename
|
||||
# Set the filename.
|
||||
root.filename = fs.realpathSync options.fileName or '.'
|
||||
# Clear the module cache
|
||||
# Clear the module cache.
|
||||
root.moduleCache = {} if root.moduleCache
|
||||
# Compile
|
||||
# Compile.
|
||||
if path.extname(root.filename) isnt '.coffee' or require.extensions
|
||||
root._compile exports.compile(code, options), root.filename
|
||||
root._compile compile(code, options), root.filename
|
||||
else
|
||||
root._compile code, root.filename
|
||||
|
||||
|
@ -66,7 +66,7 @@ exports.run = (code, options) ->
|
|||
exports.eval = (code, options) ->
|
||||
__filename = options.fileName
|
||||
__dirname = path.dirname __filename
|
||||
eval exports.compile(code, options)
|
||||
eval compile code, options
|
||||
|
||||
# Instantiate a Lexer for our use here.
|
||||
lexer = new Lexer
|
||||
|
|
Loading…
Reference in New Issue