]> git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/ex-mode/node_modules/space-pen/node_modules/grim/node_modules/coffeestack/node_modules/coffee-script/lib/coffee-script/register.js
b1d75ca4166d6a09028f33364678b9914bb1342e
[rbdr/dotfiles] / atom / packages / ex-mode / node_modules / space-pen / node_modules / grim / node_modules / coffeestack / node_modules / coffee-script / lib / coffee-script / register.js
1 // Generated by CoffeeScript 1.8.0
2 (function() {
3 var CoffeeScript, Module, binary, child_process, ext, findExtension, fork, helpers, loadFile, path, _i, _len, _ref;
4
5 CoffeeScript = require('./coffee-script');
6
7 child_process = require('child_process');
8
9 helpers = require('./helpers');
10
11 path = require('path');
12
13 loadFile = function(module, filename) {
14 var answer;
15 answer = CoffeeScript._compileFile(filename, false);
16 return module._compile(answer, filename);
17 };
18
19 if (require.extensions) {
20 _ref = CoffeeScript.FILE_EXTENSIONS;
21 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
22 ext = _ref[_i];
23 require.extensions[ext] = loadFile;
24 }
25 Module = require('module');
26 findExtension = function(filename) {
27 var curExtension, extensions;
28 extensions = path.basename(filename).split('.');
29 if (extensions[0] === '') {
30 extensions.shift();
31 }
32 while (extensions.shift()) {
33 curExtension = '.' + extensions.join('.');
34 if (Module._extensions[curExtension]) {
35 return curExtension;
36 }
37 }
38 return '.js';
39 };
40 Module.prototype.load = function(filename) {
41 var extension;
42 this.filename = filename;
43 this.paths = Module._nodeModulePaths(path.dirname(filename));
44 extension = findExtension(filename);
45 Module._extensions[extension](this, filename);
46 return this.loaded = true;
47 };
48 }
49
50 if (child_process) {
51 fork = child_process.fork;
52 binary = require.resolve('../../bin/coffee');
53 child_process.fork = function(path, args, options) {
54 if (helpers.isCoffee(path)) {
55 if (!Array.isArray(args)) {
56 options = args || {};
57 args = [];
58 }
59 args = [path].concat(args);
60 path = binary;
61 }
62 return fork(path, args, options);
63 };
64 }
65
66 }).call(this);