forked from tophyip/hyipworld.github.io
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtry.is
53 lines (43 loc) · 1.56 KB
/
try.is
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
# https://github.com/jashkenas/coffeescript/pull/3279
# https://www.google.com/search?q=require(%27coffeescript/register%27)
---
CoffeeScript = require './'
child_process = require 'child_process'
helpers = require './helpers'
path = require 'path'
loadFile = (module, filename) ->
options = module.options or getRootModule(module).options
answer = CoffeeScript._compileFile filename, options
module._compile answer, filename
if require.extensions
for ext in CoffeeScript.FILE_EXTENSIONS
require.extensions[ext] = loadFile
Module = require 'module'
findExtension = (filename) ->
extensions = path.basename(filename).split '.'
extensions.shift() if extensions[0] is ''
while extensions.shift()
curExtension = '.' + extensions.join '.'
return curExtension if Module._extensions[curExtension]
'.js'
Module::load = (filename) ->
@filename = filename
@paths = Module._nodeModulePaths path.dirname filename
extension = findExtension filename
Module._extensions[extension](this, filename)
@loaded = true
if child_process
{fork} = child_process
binary = require.resolve '../../bin/coffee'
child_process.fork = (path, args, options) ->
if helpers.isCoffee path
unless Array.isArray args
options = args or {}
args = []
args = [path].concat args
path = binary
fork path, args, options
getRootModule = (module) ->
if module.parent then getRootModule module.parent else module
eval CoffeeScript.compile 'console.log "Mmmmm, I could really go for some #{Math.pi}"'