removing fiddling with require.paths from CoffeeScript

This commit is contained in:
Jeremy Ashkenas 2010-03-15 20:39:46 -07:00
parent 60b3103314
commit 119b80d449
17 changed files with 31 additions and 33 deletions

View File

@ -1,5 +1,5 @@
fs: require 'fs'
CoffeeScript: require 'coffee-script'
CoffeeScript: require './lib/coffee-script'
# Run a CoffeeScript through our node/coffee interpreter.
run: (args) ->

View File

@ -5,5 +5,4 @@ var path = require('path');
var fs = require('fs');
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
require.paths.unshift(lib);
require('cake').run();
require('./../lib/cake').run();

View File

@ -5,5 +5,4 @@ var path = require('path');
var fs = require('fs');
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
require.paths.unshift(lib);
require('command').run();
require('./../lib/command').run();

View File

@ -10,8 +10,8 @@
// External dependencies.
fs = require('fs');
path = require('path');
optparse = require('optparse');
CoffeeScript = require('coffee-script');
optparse = require('./optparse');
CoffeeScript = require('./coffee-script');
// Keep track of the list of defined tasks, the accepted options, and so on.
tasks = {};
options = {};

View File

@ -8,10 +8,10 @@
// execute all scripts present in `text/coffeescript` tags.
// Set up dependencies correctly for both the server and the browser.
if ((typeof process !== "undefined" && process !== null)) {
process.mixin(require('nodes'));
process.mixin(require('./nodes'));
path = require('path');
Lexer = require('lexer').Lexer;
parser = require('parser').parser;
Lexer = require('./lexer').Lexer;
parser = require('./parser').parser;
} else {
this.exports = (this.CoffeeScript = {});
Lexer = this.Lexer;

View File

@ -8,8 +8,8 @@
// External dependencies.
fs = require('fs');
path = require('path');
optparse = require('optparse');
CoffeeScript = require('coffee-script');
optparse = require('./optparse');
CoffeeScript = require('./coffee-script');
// The help banner that is printed when `coffee` is called without arguments.
BANNER = "coffee compiles CoffeeScript source files into JavaScript.\n\nUsage:\n coffee path/to/script.coffee";
// The list of all the valid option flags that `coffee` knows how to handle.
@ -31,7 +31,7 @@
return version();
}
if (options.interactive) {
return require('repl');
return require('./repl');
}
if (options.stdio) {
return compile_stdio();

View File

@ -8,8 +8,8 @@
// Which is a format that can be fed directly into [Jison](http://github.com/zaach/jison).
// Set up the Lexer for both Node.js and the browser, depending on where we are.
if ((typeof process !== "undefined" && process !== null)) {
Rewriter = require('rewriter').Rewriter;
helpers = require('helpers').helpers;
Rewriter = require('./rewriter').Rewriter;
helpers = require('./helpers').helpers;
} else {
this.exports = this;
Rewriter = this.Rewriter;

View File

@ -14,8 +14,8 @@
// Set up for both **Node.js** and the browser, by
// including the [Scope](scope.html) class.
if ((typeof process !== "undefined" && process !== null)) {
Scope = require('scope').Scope;
helpers = require('helpers').helpers;
Scope = require('./scope').Scope;
helpers = require('./helpers').helpers;
} else {
this.exports = this;
}

View File

@ -5,7 +5,7 @@
// Using it looks like this:
// coffee> puts "$num bottles of beer" for num in [99..1]
// Require the **coffee-script** module to get access to the compiler.
CoffeeScript = require('coffee-script');
CoffeeScript = require('./coffee-script');
// Our prompt.
prompt = 'coffee> ';
// Quick alias for quitting the REPL.

View File

@ -9,7 +9,7 @@
// add implicit indentation and parentheses, balance incorrect nestings, and
// generally clean things up.
// Set up exported variables for both Node.js and the browser.
(typeof process !== "undefined" && process !== null) ? (helpers = require('helpers').helpers) : (this.exports = this);
(typeof process !== "undefined" && process !== null) ? (helpers = require('./helpers').helpers) : (this.exports = this);
// Import the helpers we need.
include = helpers.include;
// The **Rewriter** class is used by the [Lexer](lexer.html), directly against

View File

@ -9,8 +9,8 @@
# External dependencies.
fs: require 'fs'
path: require 'path'
optparse: require 'optparse'
CoffeeScript: require 'coffee-script'
optparse: require './optparse'
CoffeeScript: require './coffee-script'
# Keep track of the list of defined tasks, the accepted options, and so on.
tasks: {}

View File

@ -8,10 +8,10 @@
# Set up dependencies correctly for both the server and the browser.
if process?
process.mixin require 'nodes'
process.mixin require './nodes'
path: require 'path'
Lexer: require('lexer').Lexer
parser: require('parser').parser
Lexer: require('./lexer').Lexer
parser: require('./parser').parser
else
this.exports: this.CoffeeScript: {}
Lexer: this.Lexer

View File

@ -7,8 +7,8 @@
# External dependencies.
fs: require 'fs'
path: require 'path'
optparse: require 'optparse'
CoffeeScript: require 'coffee-script'
optparse: require './optparse'
CoffeeScript: require './coffee-script'
# The help banner that is printed when `coffee` is called without arguments.
BANNER: '''
@ -47,7 +47,7 @@ exports.run: ->
parse_options()
return usage() if options.help
return version() if options.version
return require 'repl' if options.interactive
return require './repl' if options.interactive
return compile_stdio() if options.stdio
return compile_script 'console', sources[0] if options.eval
return usage() unless sources.length

View File

@ -9,8 +9,8 @@
# Set up the Lexer for both Node.js and the browser, depending on where we are.
if process?
Rewriter: require('rewriter').Rewriter
helpers: require('helpers').helpers
Rewriter: require('./rewriter').Rewriter
helpers: require('./helpers').helpers
else
this.exports: this
Rewriter: this.Rewriter

View File

@ -6,8 +6,8 @@
# Set up for both **Node.js** and the browser, by
# including the [Scope](scope.html) class.
if process?
Scope: require('scope').Scope
helpers: require('helpers').helpers
Scope: require('./scope').Scope
helpers: require('./helpers').helpers
else
this.exports: this

View File

@ -5,7 +5,7 @@
# coffee> puts "$num bottles of beer" for num in [99..1]
# Require the **coffee-script** module to get access to the compiler.
CoffeeScript: require 'coffee-script'
CoffeeScript: require './coffee-script'
# Our prompt.
prompt: 'coffee> '

View File

@ -8,7 +8,7 @@
# Set up exported variables for both Node.js and the browser.
if process?
helpers: require('helpers').helpers
helpers: require('./helpers').helpers
else
this.exports: this