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

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' fs: require 'fs'
CoffeeScript: require 'coffee-script' CoffeeScript: require './lib/coffee-script'
# Run a CoffeeScript through our node/coffee interpreter. # Run a CoffeeScript through our node/coffee interpreter.
run: (args) -> run: (args) ->

View file

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

View file

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

View file

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

View file

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

View file

@ -8,8 +8,8 @@
// External dependencies. // External dependencies.
fs = require('fs'); fs = require('fs');
path = require('path'); path = require('path');
optparse = require('optparse'); optparse = require('./optparse');
CoffeeScript = require('coffee-script'); CoffeeScript = require('./coffee-script');
// The help banner that is printed when `coffee` is called without arguments. // 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"; 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. // The list of all the valid option flags that `coffee` knows how to handle.
@ -31,7 +31,7 @@
return version(); return version();
} }
if (options.interactive) { if (options.interactive) {
return require('repl'); return require('./repl');
} }
if (options.stdio) { if (options.stdio) {
return compile_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). // 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. // Set up the Lexer for both Node.js and the browser, depending on where we are.
if ((typeof process !== "undefined" && process !== null)) { if ((typeof process !== "undefined" && process !== null)) {
Rewriter = require('rewriter').Rewriter; Rewriter = require('./rewriter').Rewriter;
helpers = require('helpers').helpers; helpers = require('./helpers').helpers;
} else { } else {
this.exports = this; this.exports = this;
Rewriter = this.Rewriter; Rewriter = this.Rewriter;

View file

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

View file

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

View file

@ -9,7 +9,7 @@
// add implicit indentation and parentheses, balance incorrect nestings, and // add implicit indentation and parentheses, balance incorrect nestings, and
// generally clean things up. // generally clean things up.
// Set up exported variables for both Node.js and the browser. // 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. // Import the helpers we need.
include = helpers.include; include = helpers.include;
// The **Rewriter** class is used by the [Lexer](lexer.html), directly against // The **Rewriter** class is used by the [Lexer](lexer.html), directly against

View file

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

View file

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

View file

@ -7,8 +7,8 @@
# External dependencies. # External dependencies.
fs: require 'fs' fs: require 'fs'
path: require 'path' path: require 'path'
optparse: require 'optparse' optparse: require './optparse'
CoffeeScript: require 'coffee-script' CoffeeScript: require './coffee-script'
# The help banner that is printed when `coffee` is called without arguments. # The help banner that is printed when `coffee` is called without arguments.
BANNER: ''' BANNER: '''
@ -47,7 +47,7 @@ exports.run: ->
parse_options() parse_options()
return usage() if options.help return usage() if options.help
return version() if options.version 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_stdio() if options.stdio
return compile_script 'console', sources[0] if options.eval return compile_script 'console', sources[0] if options.eval
return usage() unless sources.length 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. # Set up the Lexer for both Node.js and the browser, depending on where we are.
if process? if process?
Rewriter: require('rewriter').Rewriter Rewriter: require('./rewriter').Rewriter
helpers: require('helpers').helpers helpers: require('./helpers').helpers
else else
this.exports: this this.exports: this
Rewriter: this.Rewriter Rewriter: this.Rewriter

View file

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

View file

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

View file

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