removing deprecated references to process.mixin in favor of helpers.extend for Node 0.1.32

This commit is contained in:
Jeremy Ashkenas 2010-03-15 22:53:25 -07:00
parent 3aeb8c6bdb
commit 02f4cb75dd
13 changed files with 39 additions and 18 deletions

View File

@ -1,4 +1,5 @@
fs: require 'fs'
helpers: require('./helpers').helpers
CoffeeScript: require './lib/coffee-script'
# Run a CoffeeScript through our node/coffee interpreter.
@ -68,11 +69,11 @@ task 'doc:underscore', 'rebuild the Underscore.coffee documentation page', ->
task 'test', 'run the CoffeeScript language test suite', ->
process.mixin require 'assert'
helpers.extend global, require 'assert'
test_count: 0
start_time: new Date()
[original_ok, original_throws]: [ok, throws]
process.mixin {
helpers.extend global, {
ok: (args...) -> test_count += 1; original_ok(args...)
throws: (args...) -> test_count += 1; original_throws(args...)
CoffeeScript: CoffeeScript

View File

@ -1,6 +1,7 @@
#!/usr/bin/env node
process.mixin(require('sys'));
require('./../lib/helpers').helpers.extend(global, require('sys'));
var path = require('path');
var fs = require('fs');
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');

View File

@ -1,6 +1,7 @@
#!/usr/bin/env node
process.mixin(require('sys'));
require('./../lib/helpers').helpers.extend(global, require('sys'));
var path = require('path');
var fs = require('fs');
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');

View File

@ -1,5 +1,3 @@
process.mixin require 'assert'
task 'test', 'run each of the unit tests', ->
for test in test_files
fs.readFile test, (err, code) -> eval coffee.compile code

View File

@ -1,6 +1,6 @@
# Contributed by Jason Huggins
process.mixin require 'sys'
sys: require 'sys'
http: require 'http'
server: http.createServer (req, res) ->
@ -10,4 +10,4 @@ server: http.createServer (req, res) ->
server.listen 3000
puts "Server running at http://localhost:3000/"
sys.puts "Server running at http://localhost:3000/"

View File

@ -1,5 +1,5 @@
(function(){
var CoffeeScript, fs, no_such_task, oparse, options, optparse, path, print_tasks, switches, tasks;
var CoffeeScript, fs, helpers, no_such_task, oparse, options, optparse, path, print_tasks, switches, tasks;
var __hasProp = Object.prototype.hasOwnProperty;
// `cake` is a simplified version of [Make](http://www.gnu.org/software/make/)
// ([Rake](http://rake.rubyforge.org/), [Jake](http://github.com/280north/jake))
@ -10,6 +10,7 @@
// External dependencies.
fs = require('fs');
path = require('path');
helpers = require('./helpers').helpers;
optparse = require('./optparse');
CoffeeScript = require('./coffee-script');
// Keep track of the list of defined tasks, the accepted options, and so on.
@ -18,7 +19,7 @@
switches = [];
oparse = null;
// Mixin the top-level Cake functions for Cakefiles to use directly.
process.mixin({
helpers.extend(global, {
// Define a Cake task with a short name, a sentence description,
// and the function to run as the action itself.
task: function task(name, description, action) {

View File

@ -1,5 +1,5 @@
(function(){
var Lexer, lexer, parser, path, process_scripts;
var Lexer, helpers, lexer, parser, path, process_scripts;
// CoffeeScript can be used both on the server, as a command-line compiler based
// on Node.js/V8, or to run CoffeeScripts directly in the browser. This module
// contains the main entry functions for tokenzing, parsing, and compiling source
@ -8,10 +8,11 @@
// 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'));
path = require('path');
Lexer = require('./lexer').Lexer;
parser = require('./parser').parser;
helpers = require('./helpers').helpers;
helpers.extend(global, require('./nodes'));
} else {
this.exports = (this.CoffeeScript = {});
Lexer = this.Lexer;

View File

@ -1,5 +1,5 @@
(function(){
var balanced_string, compact, count, del, flatten, helpers, include, merge, starts;
var balanced_string, compact, count, del, extend, flatten, helpers, include, merge, starts;
var __hasProp = Object.prototype.hasOwnProperty;
// This file contains the common helper functions that we'd like to share among
// the **Lexer**, **Rewriter**, and the **Nodes**. Merge objects, flatten
@ -60,6 +60,16 @@
}
return fresh;
});
// Extend a source object with the properties of another object (shallow copy).
helpers.extend = (extend = function extend(object, properties) {
var _a, _b, key, val;
_a = []; _b = properties;
for (key in _b) { if (__hasProp.call(_b, key)) {
val = _b[key];
_a.push(((object[key] = val)));
}}
return _a;
});
// Return a completely flattened version of an array. Handy for getting a
// list of `children` from the nodes.
helpers.flatten = (flatten = function flatten(array) {

View File

@ -1,15 +1,16 @@
(function(){
var CoffeeScript, prompt, run;
var CoffeeScript, helpers, prompt, run;
// A very simple Read-Eval-Print-Loop. Compiles one line at a time to JavaScript
// and evaluates it. Good for simple tests, or poking around the **Node.js** API.
// 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');
helpers = require('./helpers').helpers;
// Our prompt.
prompt = 'coffee> ';
// Quick alias for quitting the REPL.
process.mixin({
helpers.extend(global, {
quit: function quit() {
return process.exit(0);
}

View File

@ -9,6 +9,7 @@
# External dependencies.
fs: require 'fs'
path: require 'path'
helpers: require('./helpers').helpers
optparse: require './optparse'
CoffeeScript: require './coffee-script'
@ -19,7 +20,7 @@ switches: []
oparse: null
# Mixin the top-level Cake functions for Cakefiles to use directly.
process.mixin {
helpers.extend global, {
# Define a Cake task with a short name, a sentence description,
# and the function to run as the action itself.

View File

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

View File

@ -35,6 +35,10 @@ helpers.merge: merge: (options, overrides) ->
(fresh[key]: val) for key, val of overrides if overrides
fresh
# Extend a source object with the properties of another object (shallow copy).
helpers.extend: extend: (object, properties) ->
(object[key]: val) for key, val of properties
# Return a completely flattened version of an array. Handy for getting a
# list of `children` from the nodes.
helpers.flatten: flatten: (array) ->

View File

@ -6,12 +6,13 @@
# Require the **coffee-script** module to get access to the compiler.
CoffeeScript: require './coffee-script'
helpers: require('./helpers').helpers
# Our prompt.
prompt: 'coffee> '
# Quick alias for quitting the REPL.
process.mixin {
helpers.extend global, {
quit: -> process.exit(0)
}