batman-rails-flo 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/lib/batman-rails-flo.rb +5 -0
- data/lib/batman_rails_flo/railtie.rb +9 -0
- data/lib/batman_rails_flo/tasks.rake +14 -0
- data/lib/batman_rails_flo/version.rb +3 -0
- data/vendor/assets/javascripts/batman_rails_flo/flo_server.js +67 -0
- data/vendor/assets/javascripts/batman_rails_flo/live_reload.js.coffee +129 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/CNAME +1 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/CONTRIBUTING.md +9 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/LICENSE +22 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/README +50 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/bin/cake +7 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/bin/coffee +7 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/browser.js +134 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/cake.js +112 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/coffee-script.js +335 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/command.js +569 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/grammar.js +631 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/helpers.js +252 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/index.js +11 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/lexer.js +926 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/nodes.js +3158 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/optparse.js +139 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/parser.js +724 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/register.js +66 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/repl.js +163 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/rewriter.js +475 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/scope.js +146 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/sourcemap.js +161 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/LICENSE +21 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/examples/pow.js +6 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/index.js +82 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/package.json +34 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/readme.markdown +63 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/chmod.js +38 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/clobber.js +37 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/mkdirp.js +28 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/perm.js +32 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/perm_sync.js +39 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/race.js +41 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/rel.js +32 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/return.js +25 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/return_sync.js +24 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/root.js +18 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/sync.js +32 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/umask.js +28 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/umask_sync.js +32 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/package.json +50 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/register.js +1 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/LICENSE +30 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/PATENTS +23 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/README.md +124 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/bin/flo +26 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/configure/configure.html +57 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/configure/configure.js +205 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/configure/style.css +334 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/connection.js +235 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/devtools.html +12 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/index.js +323 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/logger.js +42 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/logo.png +0 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/manifest.json +13 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/session.js +305 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/index.js +10 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/lib/flo.js +226 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/lib/server.js +94 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/README.md +66 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/index.js +437 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/LICENSE +23 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/README.md +218 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/minimatch.js +1055 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/CONTRIBUTORS +14 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/LICENSE +23 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/README.md +97 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js +252 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/package.json +33 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/test/basic.js +369 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/test/foreach.js +52 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/test/memory-leak.js +50 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/LICENSE +27 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/README.md +53 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/bench.js +283 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/package.json +42 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/sigmund.js +39 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/test/basic.js +24 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/package.json +40 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/basic.js +399 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/brace-expand.js +33 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/caching.js +14 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/defaults.js +274 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/extglob-ending-with-state-char.js +8 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/lib/walker.js +111 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/license +13 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/lib/makeerror.js +87 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/node_modules/tmpl/lib/tmpl.js +17 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/node_modules/tmpl/package.json +31 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/node_modules/tmpl/readme.md +10 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/package.json +34 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/readme.md +77 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/package.json +36 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/readme.md +52 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/LICENSE +55 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/main.js +128 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/package.json +34 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/readme.mkd +72 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/d/d/t +0 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/d/t +0 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/test_monitor.js +31 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/test_monitorRootDirectory.js +28 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/test_watchTree.js +20 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/package.json +45 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/test/test.js +243 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/CHANGELOG.md +81 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/LICENSE +177 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/Makefile +11 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/README.md +245 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/binding.gyp +14 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Makefile +355 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/linker.lock +0 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/obj.target/validation/src/validation.o +0 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/obj.target/xor/src/xor.o +0 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/validation.node +0 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/xor.node +0 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/binding.Makefile +6 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/config.gypi +115 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/gyp-mac-tool +512 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/validation.target.mk +154 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/xor.target.mk +154 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/index.js +1 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/install.js +31 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/Constants.js +23 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/Deprecation.js +38 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/Validation.fallback.js +12 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/Validation.js +18 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketClient.js +359 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketConnection.js +717 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketFrame.js +282 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketRequest.js +478 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketRouter.js +154 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketRouterRequest.js +59 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketServer.js +216 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/utils.js +7 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/websocket.js +11 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/xor.fallback.js +13 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/xor.js +18 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/package.json +43 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/src/validation.cc +144 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/src/xor.cpp +86 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/vendor/FastBufferList.js +192 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/vendor/node-ctype/LICENSE +18 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/vendor/node-ctype/ctio-faster.js +1126 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/package.json +25 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/client/browser_websocket.js +63 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/client/connection_test.js +57 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/client/logger_mock.js +15 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/client/session_test.js +194 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/server/flo_test.js +211 -0
- data/vendor/assets/javascripts/batman_rails_flo/package.json +15 -0
- data/vendor/assets/javascripts/batman_rails_flo/reload_event_handler.js.coffee +56 -0
- metadata +232 -0
data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/cake.js
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
// Generated by CoffeeScript 1.7.1
|
2
|
+
(function() {
|
3
|
+
var CoffeeScript, cakefileDirectory, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;
|
4
|
+
|
5
|
+
fs = require('fs');
|
6
|
+
|
7
|
+
path = require('path');
|
8
|
+
|
9
|
+
helpers = require('./helpers');
|
10
|
+
|
11
|
+
optparse = require('./optparse');
|
12
|
+
|
13
|
+
CoffeeScript = require('./coffee-script');
|
14
|
+
|
15
|
+
tasks = {};
|
16
|
+
|
17
|
+
options = {};
|
18
|
+
|
19
|
+
switches = [];
|
20
|
+
|
21
|
+
oparse = null;
|
22
|
+
|
23
|
+
helpers.extend(global, {
|
24
|
+
task: function(name, description, action) {
|
25
|
+
var _ref;
|
26
|
+
if (!action) {
|
27
|
+
_ref = [description, action], action = _ref[0], description = _ref[1];
|
28
|
+
}
|
29
|
+
return tasks[name] = {
|
30
|
+
name: name,
|
31
|
+
description: description,
|
32
|
+
action: action
|
33
|
+
};
|
34
|
+
},
|
35
|
+
option: function(letter, flag, description) {
|
36
|
+
return switches.push([letter, flag, description]);
|
37
|
+
},
|
38
|
+
invoke: function(name) {
|
39
|
+
if (!tasks[name]) {
|
40
|
+
missingTask(name);
|
41
|
+
}
|
42
|
+
return tasks[name].action(options);
|
43
|
+
}
|
44
|
+
});
|
45
|
+
|
46
|
+
exports.run = function() {
|
47
|
+
var arg, args, e, _i, _len, _ref, _results;
|
48
|
+
global.__originalDirname = fs.realpathSync('.');
|
49
|
+
process.chdir(cakefileDirectory(__originalDirname));
|
50
|
+
args = process.argv.slice(2);
|
51
|
+
CoffeeScript.run(fs.readFileSync('Cakefile').toString(), {
|
52
|
+
filename: 'Cakefile'
|
53
|
+
});
|
54
|
+
oparse = new optparse.OptionParser(switches);
|
55
|
+
if (!args.length) {
|
56
|
+
return printTasks();
|
57
|
+
}
|
58
|
+
try {
|
59
|
+
options = oparse.parse(args);
|
60
|
+
} catch (_error) {
|
61
|
+
e = _error;
|
62
|
+
return fatalError("" + e);
|
63
|
+
}
|
64
|
+
_ref = options["arguments"];
|
65
|
+
_results = [];
|
66
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
67
|
+
arg = _ref[_i];
|
68
|
+
_results.push(invoke(arg));
|
69
|
+
}
|
70
|
+
return _results;
|
71
|
+
};
|
72
|
+
|
73
|
+
printTasks = function() {
|
74
|
+
var cakefilePath, desc, name, relative, spaces, task;
|
75
|
+
relative = path.relative || path.resolve;
|
76
|
+
cakefilePath = path.join(relative(__originalDirname, process.cwd()), 'Cakefile');
|
77
|
+
console.log("" + cakefilePath + " defines the following tasks:\n");
|
78
|
+
for (name in tasks) {
|
79
|
+
task = tasks[name];
|
80
|
+
spaces = 20 - name.length;
|
81
|
+
spaces = spaces > 0 ? Array(spaces + 1).join(' ') : '';
|
82
|
+
desc = task.description ? "# " + task.description : '';
|
83
|
+
console.log("cake " + name + spaces + " " + desc);
|
84
|
+
}
|
85
|
+
if (switches.length) {
|
86
|
+
return console.log(oparse.help());
|
87
|
+
}
|
88
|
+
};
|
89
|
+
|
90
|
+
fatalError = function(message) {
|
91
|
+
console.error(message + '\n');
|
92
|
+
console.log('To see a list of all tasks/options, run "cake"');
|
93
|
+
return process.exit(1);
|
94
|
+
};
|
95
|
+
|
96
|
+
missingTask = function(task) {
|
97
|
+
return fatalError("No such task: " + task);
|
98
|
+
};
|
99
|
+
|
100
|
+
cakefileDirectory = function(dir) {
|
101
|
+
var parent;
|
102
|
+
if (fs.existsSync(path.join(dir, 'Cakefile'))) {
|
103
|
+
return dir;
|
104
|
+
}
|
105
|
+
parent = path.normalize(path.join(dir, '..'));
|
106
|
+
if (parent !== dir) {
|
107
|
+
return cakefileDirectory(parent);
|
108
|
+
}
|
109
|
+
throw new Error("Cakefile not found in " + (process.cwd()));
|
110
|
+
};
|
111
|
+
|
112
|
+
}).call(this);
|
@@ -0,0 +1,335 @@
|
|
1
|
+
// Generated by CoffeeScript 1.7.1
|
2
|
+
(function() {
|
3
|
+
var Lexer, SourceMap, compile, formatSourcePosition, fs, getSourceMap, helpers, lexer, parser, path, sourceMaps, vm, withPrettyErrors,
|
4
|
+
__hasProp = {}.hasOwnProperty,
|
5
|
+
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
6
|
+
|
7
|
+
fs = require('fs');
|
8
|
+
|
9
|
+
vm = require('vm');
|
10
|
+
|
11
|
+
path = require('path');
|
12
|
+
|
13
|
+
Lexer = require('./lexer').Lexer;
|
14
|
+
|
15
|
+
parser = require('./parser').parser;
|
16
|
+
|
17
|
+
helpers = require('./helpers');
|
18
|
+
|
19
|
+
SourceMap = require('./sourcemap');
|
20
|
+
|
21
|
+
exports.VERSION = '1.7.1';
|
22
|
+
|
23
|
+
exports.FILE_EXTENSIONS = ['.coffee', '.litcoffee', '.coffee.md'];
|
24
|
+
|
25
|
+
exports.helpers = helpers;
|
26
|
+
|
27
|
+
withPrettyErrors = function(fn) {
|
28
|
+
return function(code, options) {
|
29
|
+
var err;
|
30
|
+
if (options == null) {
|
31
|
+
options = {};
|
32
|
+
}
|
33
|
+
try {
|
34
|
+
return fn.call(this, code, options);
|
35
|
+
} catch (_error) {
|
36
|
+
err = _error;
|
37
|
+
throw helpers.updateSyntaxError(err, code, options.filename);
|
38
|
+
}
|
39
|
+
};
|
40
|
+
};
|
41
|
+
|
42
|
+
exports.compile = compile = withPrettyErrors(function(code, options) {
|
43
|
+
var answer, currentColumn, currentLine, extend, fragment, fragments, header, js, map, merge, newLines, _i, _len;
|
44
|
+
merge = helpers.merge, extend = helpers.extend;
|
45
|
+
options = extend({}, options);
|
46
|
+
if (options.sourceMap) {
|
47
|
+
map = new SourceMap;
|
48
|
+
}
|
49
|
+
fragments = parser.parse(lexer.tokenize(code, options)).compileToFragments(options);
|
50
|
+
currentLine = 0;
|
51
|
+
if (options.header) {
|
52
|
+
currentLine += 1;
|
53
|
+
}
|
54
|
+
if (options.shiftLine) {
|
55
|
+
currentLine += 1;
|
56
|
+
}
|
57
|
+
currentColumn = 0;
|
58
|
+
js = "";
|
59
|
+
for (_i = 0, _len = fragments.length; _i < _len; _i++) {
|
60
|
+
fragment = fragments[_i];
|
61
|
+
if (options.sourceMap) {
|
62
|
+
if (fragment.locationData) {
|
63
|
+
map.add([fragment.locationData.first_line, fragment.locationData.first_column], [currentLine, currentColumn], {
|
64
|
+
noReplace: true
|
65
|
+
});
|
66
|
+
}
|
67
|
+
newLines = helpers.count(fragment.code, "\n");
|
68
|
+
currentLine += newLines;
|
69
|
+
if (newLines) {
|
70
|
+
currentColumn = fragment.code.length - (fragment.code.lastIndexOf("\n") + 1);
|
71
|
+
} else {
|
72
|
+
currentColumn += fragment.code.length;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
js += fragment.code;
|
76
|
+
}
|
77
|
+
if (options.header) {
|
78
|
+
header = "Generated by CoffeeScript " + this.VERSION;
|
79
|
+
js = "// " + header + "\n" + js;
|
80
|
+
}
|
81
|
+
if (options.sourceMap) {
|
82
|
+
answer = {
|
83
|
+
js: js
|
84
|
+
};
|
85
|
+
answer.sourceMap = map;
|
86
|
+
answer.v3SourceMap = map.generate(options, code);
|
87
|
+
return answer;
|
88
|
+
} else {
|
89
|
+
return js;
|
90
|
+
}
|
91
|
+
});
|
92
|
+
|
93
|
+
exports.tokens = withPrettyErrors(function(code, options) {
|
94
|
+
return lexer.tokenize(code, options);
|
95
|
+
});
|
96
|
+
|
97
|
+
exports.nodes = withPrettyErrors(function(source, options) {
|
98
|
+
if (typeof source === 'string') {
|
99
|
+
return parser.parse(lexer.tokenize(source, options));
|
100
|
+
} else {
|
101
|
+
return parser.parse(source);
|
102
|
+
}
|
103
|
+
});
|
104
|
+
|
105
|
+
exports.run = function(code, options) {
|
106
|
+
var answer, dir, mainModule, _ref;
|
107
|
+
if (options == null) {
|
108
|
+
options = {};
|
109
|
+
}
|
110
|
+
mainModule = require.main;
|
111
|
+
mainModule.filename = process.argv[1] = options.filename ? fs.realpathSync(options.filename) : '.';
|
112
|
+
mainModule.moduleCache && (mainModule.moduleCache = {});
|
113
|
+
dir = options.filename ? path.dirname(fs.realpathSync(options.filename)) : fs.realpathSync('.');
|
114
|
+
mainModule.paths = require('module')._nodeModulePaths(dir);
|
115
|
+
if (!helpers.isCoffee(mainModule.filename) || require.extensions) {
|
116
|
+
answer = compile(code, options);
|
117
|
+
code = (_ref = answer.js) != null ? _ref : answer;
|
118
|
+
}
|
119
|
+
return mainModule._compile(code, mainModule.filename);
|
120
|
+
};
|
121
|
+
|
122
|
+
exports["eval"] = function(code, options) {
|
123
|
+
var Module, Script, js, k, o, r, sandbox, v, _i, _len, _module, _ref, _ref1, _require;
|
124
|
+
if (options == null) {
|
125
|
+
options = {};
|
126
|
+
}
|
127
|
+
if (!(code = code.trim())) {
|
128
|
+
return;
|
129
|
+
}
|
130
|
+
Script = vm.Script;
|
131
|
+
if (Script) {
|
132
|
+
if (options.sandbox != null) {
|
133
|
+
if (options.sandbox instanceof Script.createContext().constructor) {
|
134
|
+
sandbox = options.sandbox;
|
135
|
+
} else {
|
136
|
+
sandbox = Script.createContext();
|
137
|
+
_ref = options.sandbox;
|
138
|
+
for (k in _ref) {
|
139
|
+
if (!__hasProp.call(_ref, k)) continue;
|
140
|
+
v = _ref[k];
|
141
|
+
sandbox[k] = v;
|
142
|
+
}
|
143
|
+
}
|
144
|
+
sandbox.global = sandbox.root = sandbox.GLOBAL = sandbox;
|
145
|
+
} else {
|
146
|
+
sandbox = global;
|
147
|
+
}
|
148
|
+
sandbox.__filename = options.filename || 'eval';
|
149
|
+
sandbox.__dirname = path.dirname(sandbox.__filename);
|
150
|
+
if (!(sandbox !== global || sandbox.module || sandbox.require)) {
|
151
|
+
Module = require('module');
|
152
|
+
sandbox.module = _module = new Module(options.modulename || 'eval');
|
153
|
+
sandbox.require = _require = function(path) {
|
154
|
+
return Module._load(path, _module, true);
|
155
|
+
};
|
156
|
+
_module.filename = sandbox.__filename;
|
157
|
+
_ref1 = Object.getOwnPropertyNames(require);
|
158
|
+
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
159
|
+
r = _ref1[_i];
|
160
|
+
if (r !== 'paths') {
|
161
|
+
_require[r] = require[r];
|
162
|
+
}
|
163
|
+
}
|
164
|
+
_require.paths = _module.paths = Module._nodeModulePaths(process.cwd());
|
165
|
+
_require.resolve = function(request) {
|
166
|
+
return Module._resolveFilename(request, _module);
|
167
|
+
};
|
168
|
+
}
|
169
|
+
}
|
170
|
+
o = {};
|
171
|
+
for (k in options) {
|
172
|
+
if (!__hasProp.call(options, k)) continue;
|
173
|
+
v = options[k];
|
174
|
+
o[k] = v;
|
175
|
+
}
|
176
|
+
o.bare = true;
|
177
|
+
js = compile(code, o);
|
178
|
+
if (sandbox === global) {
|
179
|
+
return vm.runInThisContext(js);
|
180
|
+
} else {
|
181
|
+
return vm.runInContext(js, sandbox);
|
182
|
+
}
|
183
|
+
};
|
184
|
+
|
185
|
+
exports.register = function() {
|
186
|
+
return require('./register');
|
187
|
+
};
|
188
|
+
|
189
|
+
exports._compileFile = function(filename, sourceMap) {
|
190
|
+
var answer, err, raw, stripped;
|
191
|
+
if (sourceMap == null) {
|
192
|
+
sourceMap = false;
|
193
|
+
}
|
194
|
+
raw = fs.readFileSync(filename, 'utf8');
|
195
|
+
stripped = raw.charCodeAt(0) === 0xFEFF ? raw.substring(1) : raw;
|
196
|
+
try {
|
197
|
+
answer = compile(stripped, {
|
198
|
+
filename: filename,
|
199
|
+
sourceMap: sourceMap,
|
200
|
+
literate: helpers.isLiterate(filename)
|
201
|
+
});
|
202
|
+
} catch (_error) {
|
203
|
+
err = _error;
|
204
|
+
throw helpers.updateSyntaxError(err, stripped, filename);
|
205
|
+
}
|
206
|
+
return answer;
|
207
|
+
};
|
208
|
+
|
209
|
+
lexer = new Lexer;
|
210
|
+
|
211
|
+
parser.lexer = {
|
212
|
+
lex: function() {
|
213
|
+
var tag, token;
|
214
|
+
token = this.tokens[this.pos++];
|
215
|
+
if (token) {
|
216
|
+
tag = token[0], this.yytext = token[1], this.yylloc = token[2];
|
217
|
+
this.errorToken = token.origin || token;
|
218
|
+
this.yylineno = this.yylloc.first_line;
|
219
|
+
} else {
|
220
|
+
tag = '';
|
221
|
+
}
|
222
|
+
return tag;
|
223
|
+
},
|
224
|
+
setInput: function(tokens) {
|
225
|
+
this.tokens = tokens;
|
226
|
+
return this.pos = 0;
|
227
|
+
},
|
228
|
+
upcomingInput: function() {
|
229
|
+
return "";
|
230
|
+
}
|
231
|
+
};
|
232
|
+
|
233
|
+
parser.yy = require('./nodes');
|
234
|
+
|
235
|
+
parser.yy.parseError = function(message, _arg) {
|
236
|
+
var errorLoc, errorTag, errorText, errorToken, token, tokens, _ref;
|
237
|
+
token = _arg.token;
|
238
|
+
_ref = parser.lexer, errorToken = _ref.errorToken, tokens = _ref.tokens;
|
239
|
+
errorTag = errorToken[0], errorText = errorToken[1], errorLoc = errorToken[2];
|
240
|
+
errorText = errorToken === tokens[tokens.length - 1] ? 'end of input' : errorTag === 'INDENT' || errorTag === 'OUTDENT' ? 'indentation' : helpers.nameWhitespaceCharacter(errorText);
|
241
|
+
return helpers.throwSyntaxError("unexpected " + errorText, errorLoc);
|
242
|
+
};
|
243
|
+
|
244
|
+
formatSourcePosition = function(frame, getSourceMapping) {
|
245
|
+
var as, column, fileLocation, fileName, functionName, isConstructor, isMethodCall, line, methodName, source, tp, typeName;
|
246
|
+
fileName = void 0;
|
247
|
+
fileLocation = '';
|
248
|
+
if (frame.isNative()) {
|
249
|
+
fileLocation = "native";
|
250
|
+
} else {
|
251
|
+
if (frame.isEval()) {
|
252
|
+
fileName = frame.getScriptNameOrSourceURL();
|
253
|
+
if (!fileName) {
|
254
|
+
fileLocation = "" + (frame.getEvalOrigin()) + ", ";
|
255
|
+
}
|
256
|
+
} else {
|
257
|
+
fileName = frame.getFileName();
|
258
|
+
}
|
259
|
+
fileName || (fileName = "<anonymous>");
|
260
|
+
line = frame.getLineNumber();
|
261
|
+
column = frame.getColumnNumber();
|
262
|
+
source = getSourceMapping(fileName, line, column);
|
263
|
+
fileLocation = source ? "" + fileName + ":" + source[0] + ":" + source[1] : "" + fileName + ":" + line + ":" + column;
|
264
|
+
}
|
265
|
+
functionName = frame.getFunctionName();
|
266
|
+
isConstructor = frame.isConstructor();
|
267
|
+
isMethodCall = !(frame.isToplevel() || isConstructor);
|
268
|
+
if (isMethodCall) {
|
269
|
+
methodName = frame.getMethodName();
|
270
|
+
typeName = frame.getTypeName();
|
271
|
+
if (functionName) {
|
272
|
+
tp = as = '';
|
273
|
+
if (typeName && functionName.indexOf(typeName)) {
|
274
|
+
tp = "" + typeName + ".";
|
275
|
+
}
|
276
|
+
if (methodName && functionName.indexOf("." + methodName) !== functionName.length - methodName.length - 1) {
|
277
|
+
as = " [as " + methodName + "]";
|
278
|
+
}
|
279
|
+
return "" + tp + functionName + as + " (" + fileLocation + ")";
|
280
|
+
} else {
|
281
|
+
return "" + typeName + "." + (methodName || '<anonymous>') + " (" + fileLocation + ")";
|
282
|
+
}
|
283
|
+
} else if (isConstructor) {
|
284
|
+
return "new " + (functionName || '<anonymous>') + " (" + fileLocation + ")";
|
285
|
+
} else if (functionName) {
|
286
|
+
return "" + functionName + " (" + fileLocation + ")";
|
287
|
+
} else {
|
288
|
+
return fileLocation;
|
289
|
+
}
|
290
|
+
};
|
291
|
+
|
292
|
+
sourceMaps = {};
|
293
|
+
|
294
|
+
getSourceMap = function(filename) {
|
295
|
+
var answer, _ref;
|
296
|
+
if (sourceMaps[filename]) {
|
297
|
+
return sourceMaps[filename];
|
298
|
+
}
|
299
|
+
if (_ref = path != null ? path.extname(filename) : void 0, __indexOf.call(exports.FILE_EXTENSIONS, _ref) < 0) {
|
300
|
+
return;
|
301
|
+
}
|
302
|
+
answer = exports._compileFile(filename, true);
|
303
|
+
return sourceMaps[filename] = answer.sourceMap;
|
304
|
+
};
|
305
|
+
|
306
|
+
Error.prepareStackTrace = function(err, stack) {
|
307
|
+
var frame, frames, getSourceMapping, _ref;
|
308
|
+
getSourceMapping = function(filename, line, column) {
|
309
|
+
var answer, sourceMap;
|
310
|
+
sourceMap = getSourceMap(filename);
|
311
|
+
if (sourceMap) {
|
312
|
+
answer = sourceMap.sourceLocation([line - 1, column - 1]);
|
313
|
+
}
|
314
|
+
if (answer) {
|
315
|
+
return [answer[0] + 1, answer[1] + 1];
|
316
|
+
} else {
|
317
|
+
return null;
|
318
|
+
}
|
319
|
+
};
|
320
|
+
frames = (function() {
|
321
|
+
var _i, _len, _results;
|
322
|
+
_results = [];
|
323
|
+
for (_i = 0, _len = stack.length; _i < _len; _i++) {
|
324
|
+
frame = stack[_i];
|
325
|
+
if (frame.getFunction() === exports.run) {
|
326
|
+
break;
|
327
|
+
}
|
328
|
+
_results.push(" at " + (formatSourcePosition(frame, getSourceMapping)));
|
329
|
+
}
|
330
|
+
return _results;
|
331
|
+
})();
|
332
|
+
return "" + err.name + ": " + ((_ref = err.message) != null ? _ref : '') + "\n" + (frames.join('\n')) + "\n";
|
333
|
+
};
|
334
|
+
|
335
|
+
}).call(this);
|
@@ -0,0 +1,569 @@
|
|
1
|
+
// Generated by CoffeeScript 1.7.1
|
2
|
+
(function() {
|
3
|
+
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, findDirectoryIndex, forkNode, fs, helpers, hidden, joinTimeout, mkdirp, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, removeSourceDir, silentUnlink, sourceCode, sources, spawn, timeLog, usage, useWinPathSep, version, wait, watch, watchDir, watchedDirs, writeJs, _ref,
|
4
|
+
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
5
|
+
|
6
|
+
fs = require('fs');
|
7
|
+
|
8
|
+
path = require('path');
|
9
|
+
|
10
|
+
helpers = require('./helpers');
|
11
|
+
|
12
|
+
optparse = require('./optparse');
|
13
|
+
|
14
|
+
CoffeeScript = require('./coffee-script');
|
15
|
+
|
16
|
+
mkdirp = require('mkdirp');
|
17
|
+
|
18
|
+
_ref = require('child_process'), spawn = _ref.spawn, exec = _ref.exec;
|
19
|
+
|
20
|
+
EventEmitter = require('events').EventEmitter;
|
21
|
+
|
22
|
+
useWinPathSep = path.sep === '\\';
|
23
|
+
|
24
|
+
helpers.extend(CoffeeScript, new EventEmitter);
|
25
|
+
|
26
|
+
printLine = function(line) {
|
27
|
+
return process.stdout.write(line + '\n');
|
28
|
+
};
|
29
|
+
|
30
|
+
printWarn = function(line) {
|
31
|
+
return process.stderr.write(line + '\n');
|
32
|
+
};
|
33
|
+
|
34
|
+
hidden = function(file) {
|
35
|
+
return /^\.|~$/.test(file);
|
36
|
+
};
|
37
|
+
|
38
|
+
BANNER = 'Usage: coffee [options] path/to/script.coffee -- [args]\n\nIf called without options, `coffee` will run your script.';
|
39
|
+
|
40
|
+
SWITCHES = [['-b', '--bare', 'compile without a top-level function wrapper'], ['-c', '--compile', 'compile to JavaScript and save as .js files'], ['-e', '--eval', 'pass a string from the command line as input'], ['-h', '--help', 'display this help message'], ['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-j', '--join [FILE]', 'concatenate the source CoffeeScript before compiling'], ['-m', '--map', 'generate source map and save as .map files'], ['-n', '--nodes', 'print out the parse tree that the parser produces'], ['--nodejs [ARGS]', 'pass options directly to the "node" binary'], ['--no-header', 'suppress the "Generated by" header'], ['-o', '--output [DIR]', 'set the output directory for compiled JavaScript'], ['-p', '--print', 'print out the compiled JavaScript'], ['-s', '--stdio', 'listen for and compile scripts over stdio'], ['-l', '--literate', 'treat stdio as literate style coffee-script'], ['-t', '--tokens', 'print out the tokens that the lexer/rewriter produce'], ['-v', '--version', 'display the version number'], ['-w', '--watch', 'watch scripts for changes and rerun commands']];
|
41
|
+
|
42
|
+
opts = {};
|
43
|
+
|
44
|
+
sources = [];
|
45
|
+
|
46
|
+
sourceCode = [];
|
47
|
+
|
48
|
+
notSources = {};
|
49
|
+
|
50
|
+
watchedDirs = {};
|
51
|
+
|
52
|
+
optionParser = null;
|
53
|
+
|
54
|
+
exports.run = function() {
|
55
|
+
var literals, replCliOpts, source, _i, _len, _ref1, _results;
|
56
|
+
parseOptions();
|
57
|
+
replCliOpts = {
|
58
|
+
useGlobal: true
|
59
|
+
};
|
60
|
+
if (opts.nodejs) {
|
61
|
+
return forkNode();
|
62
|
+
}
|
63
|
+
if (opts.help) {
|
64
|
+
return usage();
|
65
|
+
}
|
66
|
+
if (opts.version) {
|
67
|
+
return version();
|
68
|
+
}
|
69
|
+
if (opts.interactive) {
|
70
|
+
return require('./repl').start(replCliOpts);
|
71
|
+
}
|
72
|
+
if (opts.stdio) {
|
73
|
+
return compileStdio();
|
74
|
+
}
|
75
|
+
if (opts["eval"]) {
|
76
|
+
return compileScript(null, opts["arguments"][0]);
|
77
|
+
}
|
78
|
+
if (!opts["arguments"].length) {
|
79
|
+
return require('./repl').start(replCliOpts);
|
80
|
+
}
|
81
|
+
literals = opts.run ? opts["arguments"].splice(1) : [];
|
82
|
+
process.argv = process.argv.slice(0, 2).concat(literals);
|
83
|
+
process.argv[0] = 'coffee';
|
84
|
+
if (opts.output) {
|
85
|
+
opts.output = path.resolve(opts.output);
|
86
|
+
}
|
87
|
+
if (opts.join) {
|
88
|
+
opts.join = path.resolve(opts.join);
|
89
|
+
}
|
90
|
+
_ref1 = opts["arguments"];
|
91
|
+
_results = [];
|
92
|
+
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
93
|
+
source = _ref1[_i];
|
94
|
+
source = path.resolve(source);
|
95
|
+
_results.push(compilePath(source, true, source));
|
96
|
+
}
|
97
|
+
return _results;
|
98
|
+
};
|
99
|
+
|
100
|
+
compilePath = function(source, topLevel, base) {
|
101
|
+
var code, err, file, files, stats, _i, _len, _results;
|
102
|
+
if (__indexOf.call(sources, source) >= 0 || watchedDirs[source] || !topLevel && (notSources[source] || hidden(source))) {
|
103
|
+
return;
|
104
|
+
}
|
105
|
+
try {
|
106
|
+
stats = fs.statSync(source);
|
107
|
+
} catch (_error) {
|
108
|
+
err = _error;
|
109
|
+
if (err.code === 'ENOENT') {
|
110
|
+
console.error("File not found: " + source);
|
111
|
+
process.exit(1);
|
112
|
+
}
|
113
|
+
throw err;
|
114
|
+
}
|
115
|
+
if (stats.isDirectory()) {
|
116
|
+
if (path.basename(source) === 'node_modules') {
|
117
|
+
notSources[source] = true;
|
118
|
+
return;
|
119
|
+
}
|
120
|
+
if (opts.run) {
|
121
|
+
compilePath(findDirectoryIndex(source), topLevel, base);
|
122
|
+
return;
|
123
|
+
}
|
124
|
+
if (opts.watch) {
|
125
|
+
watchDir(source, base);
|
126
|
+
}
|
127
|
+
try {
|
128
|
+
files = fs.readdirSync(source);
|
129
|
+
} catch (_error) {
|
130
|
+
err = _error;
|
131
|
+
if (err.code === 'ENOENT') {
|
132
|
+
return;
|
133
|
+
} else {
|
134
|
+
throw err;
|
135
|
+
}
|
136
|
+
}
|
137
|
+
_results = [];
|
138
|
+
for (_i = 0, _len = files.length; _i < _len; _i++) {
|
139
|
+
file = files[_i];
|
140
|
+
_results.push(compilePath(path.join(source, file), false, base));
|
141
|
+
}
|
142
|
+
return _results;
|
143
|
+
} else if (topLevel || helpers.isCoffee(source)) {
|
144
|
+
sources.push(source);
|
145
|
+
sourceCode.push(null);
|
146
|
+
delete notSources[source];
|
147
|
+
if (opts.watch) {
|
148
|
+
watch(source, base);
|
149
|
+
}
|
150
|
+
try {
|
151
|
+
code = fs.readFileSync(source);
|
152
|
+
} catch (_error) {
|
153
|
+
err = _error;
|
154
|
+
if (err.code === 'ENOENT') {
|
155
|
+
return;
|
156
|
+
} else {
|
157
|
+
throw err;
|
158
|
+
}
|
159
|
+
}
|
160
|
+
return compileScript(source, code.toString(), base);
|
161
|
+
} else {
|
162
|
+
return notSources[source] = true;
|
163
|
+
}
|
164
|
+
};
|
165
|
+
|
166
|
+
findDirectoryIndex = function(source) {
|
167
|
+
var err, ext, index, _i, _len, _ref1;
|
168
|
+
_ref1 = CoffeeScript.FILE_EXTENSIONS;
|
169
|
+
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
170
|
+
ext = _ref1[_i];
|
171
|
+
index = path.join(source, "index" + ext);
|
172
|
+
try {
|
173
|
+
if ((fs.statSync(index)).isFile()) {
|
174
|
+
return index;
|
175
|
+
}
|
176
|
+
} catch (_error) {
|
177
|
+
err = _error;
|
178
|
+
if (err.code !== 'ENOENT') {
|
179
|
+
throw err;
|
180
|
+
}
|
181
|
+
}
|
182
|
+
}
|
183
|
+
console.error("Missing index.coffee or index.litcoffee in " + source);
|
184
|
+
return process.exit(1);
|
185
|
+
};
|
186
|
+
|
187
|
+
compileScript = function(file, input, base) {
|
188
|
+
var compiled, err, message, o, options, t, task;
|
189
|
+
if (base == null) {
|
190
|
+
base = null;
|
191
|
+
}
|
192
|
+
o = opts;
|
193
|
+
options = compileOptions(file, base);
|
194
|
+
try {
|
195
|
+
t = task = {
|
196
|
+
file: file,
|
197
|
+
input: input,
|
198
|
+
options: options
|
199
|
+
};
|
200
|
+
CoffeeScript.emit('compile', task);
|
201
|
+
if (o.tokens) {
|
202
|
+
return printTokens(CoffeeScript.tokens(t.input, t.options));
|
203
|
+
} else if (o.nodes) {
|
204
|
+
return printLine(CoffeeScript.nodes(t.input, t.options).toString().trim());
|
205
|
+
} else if (o.run) {
|
206
|
+
CoffeeScript.register();
|
207
|
+
return CoffeeScript.run(t.input, t.options);
|
208
|
+
} else if (o.join && t.file !== o.join) {
|
209
|
+
if (helpers.isLiterate(file)) {
|
210
|
+
t.input = helpers.invertLiterate(t.input);
|
211
|
+
}
|
212
|
+
sourceCode[sources.indexOf(t.file)] = t.input;
|
213
|
+
return compileJoin();
|
214
|
+
} else {
|
215
|
+
compiled = CoffeeScript.compile(t.input, t.options);
|
216
|
+
t.output = compiled;
|
217
|
+
if (o.map) {
|
218
|
+
t.output = compiled.js;
|
219
|
+
t.sourceMap = compiled.v3SourceMap;
|
220
|
+
}
|
221
|
+
CoffeeScript.emit('success', task);
|
222
|
+
if (o.print) {
|
223
|
+
return printLine(t.output.trim());
|
224
|
+
} else if (o.compile || o.map) {
|
225
|
+
return writeJs(base, t.file, t.output, options.jsPath, t.sourceMap);
|
226
|
+
}
|
227
|
+
}
|
228
|
+
} catch (_error) {
|
229
|
+
err = _error;
|
230
|
+
CoffeeScript.emit('failure', err, task);
|
231
|
+
if (CoffeeScript.listeners('failure').length) {
|
232
|
+
return;
|
233
|
+
}
|
234
|
+
message = err.stack || ("" + err);
|
235
|
+
if (o.watch) {
|
236
|
+
return printLine(message + '\x07');
|
237
|
+
} else {
|
238
|
+
printWarn(message);
|
239
|
+
return process.exit(1);
|
240
|
+
}
|
241
|
+
}
|
242
|
+
};
|
243
|
+
|
244
|
+
compileStdio = function() {
|
245
|
+
var code, stdin;
|
246
|
+
code = '';
|
247
|
+
stdin = process.openStdin();
|
248
|
+
stdin.on('data', function(buffer) {
|
249
|
+
if (buffer) {
|
250
|
+
return code += buffer.toString();
|
251
|
+
}
|
252
|
+
});
|
253
|
+
return stdin.on('end', function() {
|
254
|
+
return compileScript(null, code);
|
255
|
+
});
|
256
|
+
};
|
257
|
+
|
258
|
+
joinTimeout = null;
|
259
|
+
|
260
|
+
compileJoin = function() {
|
261
|
+
if (!opts.join) {
|
262
|
+
return;
|
263
|
+
}
|
264
|
+
if (!sourceCode.some(function(code) {
|
265
|
+
return code === null;
|
266
|
+
})) {
|
267
|
+
clearTimeout(joinTimeout);
|
268
|
+
return joinTimeout = wait(100, function() {
|
269
|
+
return compileScript(opts.join, sourceCode.join('\n'), opts.join);
|
270
|
+
});
|
271
|
+
}
|
272
|
+
};
|
273
|
+
|
274
|
+
watch = function(source, base) {
|
275
|
+
var compile, compileTimeout, err, prevStats, rewatch, startWatcher, watchErr, watcher;
|
276
|
+
watcher = null;
|
277
|
+
prevStats = null;
|
278
|
+
compileTimeout = null;
|
279
|
+
watchErr = function(err) {
|
280
|
+
if (err.code !== 'ENOENT') {
|
281
|
+
throw err;
|
282
|
+
}
|
283
|
+
if (__indexOf.call(sources, source) < 0) {
|
284
|
+
return;
|
285
|
+
}
|
286
|
+
try {
|
287
|
+
rewatch();
|
288
|
+
return compile();
|
289
|
+
} catch (_error) {
|
290
|
+
removeSource(source, base);
|
291
|
+
return compileJoin();
|
292
|
+
}
|
293
|
+
};
|
294
|
+
compile = function() {
|
295
|
+
clearTimeout(compileTimeout);
|
296
|
+
return compileTimeout = wait(25, function() {
|
297
|
+
return fs.stat(source, function(err, stats) {
|
298
|
+
if (err) {
|
299
|
+
return watchErr(err);
|
300
|
+
}
|
301
|
+
if (prevStats && stats.size === prevStats.size && stats.mtime.getTime() === prevStats.mtime.getTime()) {
|
302
|
+
return rewatch();
|
303
|
+
}
|
304
|
+
prevStats = stats;
|
305
|
+
return fs.readFile(source, function(err, code) {
|
306
|
+
if (err) {
|
307
|
+
return watchErr(err);
|
308
|
+
}
|
309
|
+
compileScript(source, code.toString(), base);
|
310
|
+
return rewatch();
|
311
|
+
});
|
312
|
+
});
|
313
|
+
});
|
314
|
+
};
|
315
|
+
startWatcher = function() {
|
316
|
+
return watcher = fs.watch(source).on('change', compile).on('error', function(err) {
|
317
|
+
if (err.code !== 'EPERM') {
|
318
|
+
throw err;
|
319
|
+
}
|
320
|
+
return removeSource(source, base);
|
321
|
+
});
|
322
|
+
};
|
323
|
+
rewatch = function() {
|
324
|
+
if (watcher != null) {
|
325
|
+
watcher.close();
|
326
|
+
}
|
327
|
+
return startWatcher();
|
328
|
+
};
|
329
|
+
try {
|
330
|
+
return startWatcher();
|
331
|
+
} catch (_error) {
|
332
|
+
err = _error;
|
333
|
+
return watchErr(err);
|
334
|
+
}
|
335
|
+
};
|
336
|
+
|
337
|
+
watchDir = function(source, base) {
|
338
|
+
var err, readdirTimeout, startWatcher, stopWatcher, watcher;
|
339
|
+
watcher = null;
|
340
|
+
readdirTimeout = null;
|
341
|
+
startWatcher = function() {
|
342
|
+
return watcher = fs.watch(source).on('error', function(err) {
|
343
|
+
if (err.code !== 'EPERM') {
|
344
|
+
throw err;
|
345
|
+
}
|
346
|
+
return stopWatcher();
|
347
|
+
}).on('change', function() {
|
348
|
+
clearTimeout(readdirTimeout);
|
349
|
+
return readdirTimeout = wait(25, function() {
|
350
|
+
var err, file, files, _i, _len, _results;
|
351
|
+
try {
|
352
|
+
files = fs.readdirSync(source);
|
353
|
+
} catch (_error) {
|
354
|
+
err = _error;
|
355
|
+
if (err.code !== 'ENOENT') {
|
356
|
+
throw err;
|
357
|
+
}
|
358
|
+
return stopWatcher();
|
359
|
+
}
|
360
|
+
_results = [];
|
361
|
+
for (_i = 0, _len = files.length; _i < _len; _i++) {
|
362
|
+
file = files[_i];
|
363
|
+
_results.push(compilePath(path.join(source, file), false, base));
|
364
|
+
}
|
365
|
+
return _results;
|
366
|
+
});
|
367
|
+
});
|
368
|
+
};
|
369
|
+
stopWatcher = function() {
|
370
|
+
watcher.close();
|
371
|
+
return removeSourceDir(source, base);
|
372
|
+
};
|
373
|
+
watchedDirs[source] = true;
|
374
|
+
try {
|
375
|
+
return startWatcher();
|
376
|
+
} catch (_error) {
|
377
|
+
err = _error;
|
378
|
+
if (err.code !== 'ENOENT') {
|
379
|
+
throw err;
|
380
|
+
}
|
381
|
+
}
|
382
|
+
};
|
383
|
+
|
384
|
+
removeSourceDir = function(source, base) {
|
385
|
+
var file, sourcesChanged, _i, _len;
|
386
|
+
delete watchedDirs[source];
|
387
|
+
sourcesChanged = false;
|
388
|
+
for (_i = 0, _len = sources.length; _i < _len; _i++) {
|
389
|
+
file = sources[_i];
|
390
|
+
if (!(source === path.dirname(file))) {
|
391
|
+
continue;
|
392
|
+
}
|
393
|
+
removeSource(file, base);
|
394
|
+
sourcesChanged = true;
|
395
|
+
}
|
396
|
+
if (sourcesChanged) {
|
397
|
+
return compileJoin();
|
398
|
+
}
|
399
|
+
};
|
400
|
+
|
401
|
+
removeSource = function(source, base) {
|
402
|
+
var index;
|
403
|
+
index = sources.indexOf(source);
|
404
|
+
sources.splice(index, 1);
|
405
|
+
sourceCode.splice(index, 1);
|
406
|
+
if (!opts.join) {
|
407
|
+
silentUnlink(outputPath(source, base));
|
408
|
+
silentUnlink(outputPath(source, base, '.map'));
|
409
|
+
return timeLog("removed " + source);
|
410
|
+
}
|
411
|
+
};
|
412
|
+
|
413
|
+
silentUnlink = function(path) {
|
414
|
+
var err, _ref1;
|
415
|
+
try {
|
416
|
+
return fs.unlinkSync(path);
|
417
|
+
} catch (_error) {
|
418
|
+
err = _error;
|
419
|
+
if ((_ref1 = err.code) !== 'ENOENT' && _ref1 !== 'EPERM') {
|
420
|
+
throw err;
|
421
|
+
}
|
422
|
+
}
|
423
|
+
};
|
424
|
+
|
425
|
+
outputPath = function(source, base, extension) {
|
426
|
+
var basename, dir, srcDir;
|
427
|
+
if (extension == null) {
|
428
|
+
extension = ".js";
|
429
|
+
}
|
430
|
+
basename = helpers.baseFileName(source, true, useWinPathSep);
|
431
|
+
srcDir = path.dirname(source);
|
432
|
+
if (!opts.output) {
|
433
|
+
dir = srcDir;
|
434
|
+
} else if (source === base) {
|
435
|
+
dir = opts.output;
|
436
|
+
} else {
|
437
|
+
dir = path.join(opts.output, path.relative(base, srcDir));
|
438
|
+
}
|
439
|
+
return path.join(dir, basename + extension);
|
440
|
+
};
|
441
|
+
|
442
|
+
writeJs = function(base, sourcePath, js, jsPath, generatedSourceMap) {
|
443
|
+
var compile, jsDir, sourceMapPath;
|
444
|
+
if (generatedSourceMap == null) {
|
445
|
+
generatedSourceMap = null;
|
446
|
+
}
|
447
|
+
sourceMapPath = outputPath(sourcePath, base, ".map");
|
448
|
+
jsDir = path.dirname(jsPath);
|
449
|
+
compile = function() {
|
450
|
+
if (opts.compile) {
|
451
|
+
if (js.length <= 0) {
|
452
|
+
js = ' ';
|
453
|
+
}
|
454
|
+
if (generatedSourceMap) {
|
455
|
+
js = "" + js + "\n//# sourceMappingURL=" + (helpers.baseFileName(sourceMapPath, false, useWinPathSep)) + "\n";
|
456
|
+
}
|
457
|
+
fs.writeFile(jsPath, js, function(err) {
|
458
|
+
if (err) {
|
459
|
+
return printLine(err.message);
|
460
|
+
} else if (opts.compile && opts.watch) {
|
461
|
+
return timeLog("compiled " + sourcePath);
|
462
|
+
}
|
463
|
+
});
|
464
|
+
}
|
465
|
+
if (generatedSourceMap) {
|
466
|
+
return fs.writeFile(sourceMapPath, generatedSourceMap, function(err) {
|
467
|
+
if (err) {
|
468
|
+
return printLine("Could not write source map: " + err.message);
|
469
|
+
}
|
470
|
+
});
|
471
|
+
}
|
472
|
+
};
|
473
|
+
return fs.exists(jsDir, function(itExists) {
|
474
|
+
if (itExists) {
|
475
|
+
return compile();
|
476
|
+
} else {
|
477
|
+
return mkdirp(jsDir, compile);
|
478
|
+
}
|
479
|
+
});
|
480
|
+
};
|
481
|
+
|
482
|
+
wait = function(milliseconds, func) {
|
483
|
+
return setTimeout(func, milliseconds);
|
484
|
+
};
|
485
|
+
|
486
|
+
timeLog = function(message) {
|
487
|
+
return console.log("" + ((new Date).toLocaleTimeString()) + " - " + message);
|
488
|
+
};
|
489
|
+
|
490
|
+
printTokens = function(tokens) {
|
491
|
+
var strings, tag, token, value;
|
492
|
+
strings = (function() {
|
493
|
+
var _i, _len, _results;
|
494
|
+
_results = [];
|
495
|
+
for (_i = 0, _len = tokens.length; _i < _len; _i++) {
|
496
|
+
token = tokens[_i];
|
497
|
+
tag = token[0];
|
498
|
+
value = token[1].toString().replace(/\n/, '\\n');
|
499
|
+
_results.push("[" + tag + " " + value + "]");
|
500
|
+
}
|
501
|
+
return _results;
|
502
|
+
})();
|
503
|
+
return printLine(strings.join(' '));
|
504
|
+
};
|
505
|
+
|
506
|
+
parseOptions = function() {
|
507
|
+
var o;
|
508
|
+
optionParser = new optparse.OptionParser(SWITCHES, BANNER);
|
509
|
+
o = opts = optionParser.parse(process.argv.slice(2));
|
510
|
+
o.compile || (o.compile = !!o.output);
|
511
|
+
o.run = !(o.compile || o.print || o.map);
|
512
|
+
return o.print = !!(o.print || (o["eval"] || o.stdio && o.compile));
|
513
|
+
};
|
514
|
+
|
515
|
+
compileOptions = function(filename, base) {
|
516
|
+
var answer, cwd, jsDir, jsPath;
|
517
|
+
answer = {
|
518
|
+
filename: filename,
|
519
|
+
literate: opts.literate || helpers.isLiterate(filename),
|
520
|
+
bare: opts.bare,
|
521
|
+
header: opts.compile && !opts['no-header'],
|
522
|
+
sourceMap: opts.map
|
523
|
+
};
|
524
|
+
if (filename) {
|
525
|
+
if (base) {
|
526
|
+
cwd = process.cwd();
|
527
|
+
jsPath = outputPath(filename, base);
|
528
|
+
jsDir = path.dirname(jsPath);
|
529
|
+
answer = helpers.merge(answer, {
|
530
|
+
jsPath: jsPath,
|
531
|
+
sourceRoot: path.relative(jsDir, cwd),
|
532
|
+
sourceFiles: [path.relative(cwd, filename)],
|
533
|
+
generatedFile: helpers.baseFileName(jsPath, false, useWinPathSep)
|
534
|
+
});
|
535
|
+
} else {
|
536
|
+
answer = helpers.merge(answer, {
|
537
|
+
sourceRoot: "",
|
538
|
+
sourceFiles: [helpers.baseFileName(filename, false, useWinPathSep)],
|
539
|
+
generatedFile: helpers.baseFileName(filename, true, useWinPathSep) + ".js"
|
540
|
+
});
|
541
|
+
}
|
542
|
+
}
|
543
|
+
return answer;
|
544
|
+
};
|
545
|
+
|
546
|
+
forkNode = function() {
|
547
|
+
var args, nodeArgs, p;
|
548
|
+
nodeArgs = opts.nodejs.split(/\s+/);
|
549
|
+
args = process.argv.slice(1);
|
550
|
+
args.splice(args.indexOf('--nodejs'), 2);
|
551
|
+
p = spawn(process.execPath, nodeArgs.concat(args), {
|
552
|
+
cwd: process.cwd(),
|
553
|
+
env: process.env,
|
554
|
+
customFds: [0, 1, 2]
|
555
|
+
});
|
556
|
+
return p.on('exit', function(code) {
|
557
|
+
return process.exit(code);
|
558
|
+
});
|
559
|
+
};
|
560
|
+
|
561
|
+
usage = function() {
|
562
|
+
return printLine((new optparse.OptionParser(SWITCHES, BANNER)).help());
|
563
|
+
};
|
564
|
+
|
565
|
+
version = function() {
|
566
|
+
return printLine("CoffeeScript version " + CoffeeScript.VERSION);
|
567
|
+
};
|
568
|
+
|
569
|
+
}).call(this);
|