coffeescript-router 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. data/.gitignore +3 -0
  2. data/Cakefile +122 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +22 -0
  5. data/LICENSE.txt +19 -0
  6. data/README.md +18 -0
  7. data/Rakefile +2 -0
  8. data/SpecRunner.html +25 -0
  9. data/coffeescript-router.gemspec +19 -0
  10. data/lib/CoffeeScript.png +0 -0
  11. data/lib/coffeescript-router/version.rb +5 -0
  12. data/lib/jasmine-1.0.2/MIT.LICENSE +20 -0
  13. data/lib/jasmine-1.0.2/jasmine-html.js +188 -0
  14. data/lib/jasmine-1.0.2/jasmine.css +166 -0
  15. data/lib/jasmine-1.0.2/jasmine.js +2421 -0
  16. data/node_modules/.bin/cake +7 -0
  17. data/node_modules/.bin/coffee +7 -0
  18. data/node_modules/.bin/uglifyjs +212 -0
  19. data/node_modules/coffee-script/.npmignore +11 -0
  20. data/node_modules/coffee-script/LICENSE +22 -0
  21. data/node_modules/coffee-script/README +48 -0
  22. data/node_modules/coffee-script/Rakefile +78 -0
  23. data/node_modules/coffee-script/bin/cake +7 -0
  24. data/node_modules/coffee-script/bin/coffee +7 -0
  25. data/node_modules/coffee-script/lib/browser.js +75 -0
  26. data/node_modules/coffee-script/lib/cake.js +76 -0
  27. data/node_modules/coffee-script/lib/coffee-script.js +107 -0
  28. data/node_modules/coffee-script/lib/command.js +274 -0
  29. data/node_modules/coffee-script/lib/grammar.js +591 -0
  30. data/node_modules/coffee-script/lib/helpers.js +66 -0
  31. data/node_modules/coffee-script/lib/index.js +8 -0
  32. data/node_modules/coffee-script/lib/lexer.js +650 -0
  33. data/node_modules/coffee-script/lib/nodes.js +2230 -0
  34. data/node_modules/coffee-script/lib/optparse.js +111 -0
  35. data/node_modules/coffee-script/lib/parser.js +676 -0
  36. data/node_modules/coffee-script/lib/repl.js +114 -0
  37. data/node_modules/coffee-script/lib/rewriter.js +359 -0
  38. data/node_modules/coffee-script/lib/scope.js +120 -0
  39. data/node_modules/coffee-script/package.json +27 -0
  40. data/node_modules/growl/History.md +16 -0
  41. data/node_modules/growl/Readme.md +74 -0
  42. data/node_modules/growl/lib/growl.js +82 -0
  43. data/node_modules/growl/package.json +6 -0
  44. data/node_modules/growl/test.js +17 -0
  45. data/node_modules/uglify-js/.gitignore +4 -0
  46. data/node_modules/uglify-js/README.html +825 -0
  47. data/node_modules/uglify-js/README.org +431 -0
  48. data/node_modules/uglify-js/bin/uglifyjs +212 -0
  49. data/node_modules/uglify-js/docstyle.css +75 -0
  50. data/node_modules/uglify-js/lib/parse-js.js +1319 -0
  51. data/node_modules/uglify-js/lib/process.js +1614 -0
  52. data/node_modules/uglify-js/lib/squeeze-more.js +22 -0
  53. data/node_modules/uglify-js/package.json +22 -0
  54. data/node_modules/uglify-js/test/beautify.js +28 -0
  55. data/node_modules/uglify-js/test/testparser.js +402 -0
  56. data/node_modules/uglify-js/test/unit/compress/expected/array1.js +1 -0
  57. data/node_modules/uglify-js/test/unit/compress/expected/array2.js +1 -0
  58. data/node_modules/uglify-js/test/unit/compress/expected/array3.js +1 -0
  59. data/node_modules/uglify-js/test/unit/compress/expected/array4.js +1 -0
  60. data/node_modules/uglify-js/test/unit/compress/expected/assignment.js +1 -0
  61. data/node_modules/uglify-js/test/unit/compress/expected/concatstring.js +1 -0
  62. data/node_modules/uglify-js/test/unit/compress/expected/const.js +1 -0
  63. data/node_modules/uglify-js/test/unit/compress/expected/empty-blocks.js +1 -0
  64. data/node_modules/uglify-js/test/unit/compress/expected/forstatement.js +1 -0
  65. data/node_modules/uglify-js/test/unit/compress/expected/if.js +1 -0
  66. data/node_modules/uglify-js/test/unit/compress/expected/ifreturn.js +1 -0
  67. data/node_modules/uglify-js/test/unit/compress/expected/issue10.js +1 -0
  68. data/node_modules/uglify-js/test/unit/compress/expected/issue11.js +1 -0
  69. data/node_modules/uglify-js/test/unit/compress/expected/issue13.js +1 -0
  70. data/node_modules/uglify-js/test/unit/compress/expected/issue14.js +1 -0
  71. data/node_modules/uglify-js/test/unit/compress/expected/issue16.js +1 -0
  72. data/node_modules/uglify-js/test/unit/compress/expected/issue17.js +1 -0
  73. data/node_modules/uglify-js/test/unit/compress/expected/issue20.js +1 -0
  74. data/node_modules/uglify-js/test/unit/compress/expected/issue21.js +1 -0
  75. data/node_modules/uglify-js/test/unit/compress/expected/issue25.js +1 -0
  76. data/node_modules/uglify-js/test/unit/compress/expected/issue27.js +1 -0
  77. data/node_modules/uglify-js/test/unit/compress/expected/issue28.js +1 -0
  78. data/node_modules/uglify-js/test/unit/compress/expected/issue29.js +1 -0
  79. data/node_modules/uglify-js/test/unit/compress/expected/issue30.js +1 -0
  80. data/node_modules/uglify-js/test/unit/compress/expected/issue34.js +1 -0
  81. data/node_modules/uglify-js/test/unit/compress/expected/issue4.js +1 -0
  82. data/node_modules/uglify-js/test/unit/compress/expected/issue48.js +1 -0
  83. data/node_modules/uglify-js/test/unit/compress/expected/issue50.js +1 -0
  84. data/node_modules/uglify-js/test/unit/compress/expected/issue53.js +1 -0
  85. data/node_modules/uglify-js/test/unit/compress/expected/issue54.1.js +1 -0
  86. data/node_modules/uglify-js/test/unit/compress/expected/issue68.js +1 -0
  87. data/node_modules/uglify-js/test/unit/compress/expected/issue69.js +1 -0
  88. data/node_modules/uglify-js/test/unit/compress/expected/issue9.js +1 -0
  89. data/node_modules/uglify-js/test/unit/compress/expected/strict-equals.js +1 -0
  90. data/node_modules/uglify-js/test/unit/compress/expected/var.js +1 -0
  91. data/node_modules/uglify-js/test/unit/compress/test/array1.js +3 -0
  92. data/node_modules/uglify-js/test/unit/compress/test/array2.js +4 -0
  93. data/node_modules/uglify-js/test/unit/compress/test/array3.js +4 -0
  94. data/node_modules/uglify-js/test/unit/compress/test/array4.js +6 -0
  95. data/node_modules/uglify-js/test/unit/compress/test/assignment.js +20 -0
  96. data/node_modules/uglify-js/test/unit/compress/test/concatstring.js +3 -0
  97. data/node_modules/uglify-js/test/unit/compress/test/const.js +5 -0
  98. data/node_modules/uglify-js/test/unit/compress/test/empty-blocks.js +4 -0
  99. data/node_modules/uglify-js/test/unit/compress/test/forstatement.js +10 -0
  100. data/node_modules/uglify-js/test/unit/compress/test/if.js +6 -0
  101. data/node_modules/uglify-js/test/unit/compress/test/ifreturn.js +9 -0
  102. data/node_modules/uglify-js/test/unit/compress/test/issue10.js +1 -0
  103. data/node_modules/uglify-js/test/unit/compress/test/issue11.js +3 -0
  104. data/node_modules/uglify-js/test/unit/compress/test/issue13.js +1 -0
  105. data/node_modules/uglify-js/test/unit/compress/test/issue14.js +1 -0
  106. data/node_modules/uglify-js/test/unit/compress/test/issue16.js +1 -0
  107. data/node_modules/uglify-js/test/unit/compress/test/issue17.js +4 -0
  108. data/node_modules/uglify-js/test/unit/compress/test/issue20.js +1 -0
  109. data/node_modules/uglify-js/test/unit/compress/test/issue21.js +6 -0
  110. data/node_modules/uglify-js/test/unit/compress/test/issue25.js +7 -0
  111. data/node_modules/uglify-js/test/unit/compress/test/issue27.js +1 -0
  112. data/node_modules/uglify-js/test/unit/compress/test/issue28.js +3 -0
  113. data/node_modules/uglify-js/test/unit/compress/test/issue29.js +1 -0
  114. data/node_modules/uglify-js/test/unit/compress/test/issue30.js +3 -0
  115. data/node_modules/uglify-js/test/unit/compress/test/issue34.js +3 -0
  116. data/node_modules/uglify-js/test/unit/compress/test/issue4.js +3 -0
  117. data/node_modules/uglify-js/test/unit/compress/test/issue48.js +1 -0
  118. data/node_modules/uglify-js/test/unit/compress/test/issue50.js +9 -0
  119. data/node_modules/uglify-js/test/unit/compress/test/issue53.js +1 -0
  120. data/node_modules/uglify-js/test/unit/compress/test/issue54.1.js +3 -0
  121. data/node_modules/uglify-js/test/unit/compress/test/issue68.js +5 -0
  122. data/node_modules/uglify-js/test/unit/compress/test/issue69.js +1 -0
  123. data/node_modules/uglify-js/test/unit/compress/test/issue9.js +4 -0
  124. data/node_modules/uglify-js/test/unit/compress/test/strict-equals.js +3 -0
  125. data/node_modules/uglify-js/test/unit/compress/test/var.js +3 -0
  126. data/node_modules/uglify-js/test/unit/scripts.js +46 -0
  127. data/node_modules/uglify-js/uglify-js.js +2 -0
  128. data/src/coffeescript/coffeescript-router.js.coffee +31 -0
  129. data/test/coffeescript/routerSpec.coffee +47 -0
  130. data/vendor/assets/javascripts/coffeescript-router.min.js +1 -0
  131. metadata +187 -0
@@ -0,0 +1,76 @@
1
+ (function() {
2
+ var CoffeeScript, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;
3
+ fs = require('fs');
4
+ path = require('path');
5
+ helpers = require('./helpers');
6
+ optparse = require('./optparse');
7
+ CoffeeScript = require('./coffee-script');
8
+ tasks = {};
9
+ options = {};
10
+ switches = [];
11
+ oparse = null;
12
+ helpers.extend(global, {
13
+ task: function(name, description, action) {
14
+ var _ref;
15
+ if (!action) {
16
+ _ref = [description, action], action = _ref[0], description = _ref[1];
17
+ }
18
+ return tasks[name] = {
19
+ name: name,
20
+ description: description,
21
+ action: action
22
+ };
23
+ },
24
+ option: function(letter, flag, description) {
25
+ return switches.push([letter, flag, description]);
26
+ },
27
+ invoke: function(name) {
28
+ if (!tasks[name]) {
29
+ missingTask(name);
30
+ }
31
+ return tasks[name].action(options);
32
+ }
33
+ });
34
+ exports.run = function() {
35
+ return path.exists('Cakefile', function(exists) {
36
+ var arg, args, _i, _len, _ref, _results;
37
+ if (!exists) {
38
+ throw new Error("Cakefile not found in " + (process.cwd()));
39
+ }
40
+ args = process.argv.slice(2);
41
+ CoffeeScript.run(fs.readFileSync('Cakefile').toString(), {
42
+ filename: 'Cakefile'
43
+ });
44
+ oparse = new optparse.OptionParser(switches);
45
+ if (!args.length) {
46
+ return printTasks();
47
+ }
48
+ options = oparse.parse(args);
49
+ _ref = options.arguments;
50
+ _results = [];
51
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
52
+ arg = _ref[_i];
53
+ _results.push(invoke(arg));
54
+ }
55
+ return _results;
56
+ });
57
+ };
58
+ printTasks = function() {
59
+ var desc, name, spaces, task;
60
+ console.log('');
61
+ for (name in tasks) {
62
+ task = tasks[name];
63
+ spaces = 20 - name.length;
64
+ spaces = spaces > 0 ? Array(spaces + 1).join(' ') : '';
65
+ desc = task.description ? "# " + task.description : '';
66
+ console.log("cake " + name + spaces + " " + desc);
67
+ }
68
+ if (switches.length) {
69
+ return console.log(oparse.help());
70
+ }
71
+ };
72
+ missingTask = function(task) {
73
+ console.log("No such task: \"" + task + "\"");
74
+ return process.exit(1);
75
+ };
76
+ }).call(this);
@@ -0,0 +1,107 @@
1
+ (function() {
2
+ var Lexer, RESERVED, compile, fs, lexer, parser, path, vm, _ref;
3
+ fs = require('fs');
4
+ path = require('path');
5
+ vm = require('vm');
6
+ _ref = require('./lexer'), Lexer = _ref.Lexer, RESERVED = _ref.RESERVED;
7
+ parser = require('./parser').parser;
8
+ if (require.extensions) {
9
+ require.extensions['.coffee'] = function(module, filename) {
10
+ var content;
11
+ content = compile(fs.readFileSync(filename, 'utf8'), {
12
+ filename: filename
13
+ });
14
+ return module._compile(content, filename);
15
+ };
16
+ } else if (require.registerExtension) {
17
+ require.registerExtension('.coffee', function(content) {
18
+ return compile(content);
19
+ });
20
+ }
21
+ exports.VERSION = '1.1.0';
22
+ exports.RESERVED = RESERVED;
23
+ exports.helpers = require('./helpers');
24
+ exports.compile = compile = function(code, options) {
25
+ if (options == null) {
26
+ options = {};
27
+ }
28
+ try {
29
+ return (parser.parse(lexer.tokenize(code))).compile(options);
30
+ } catch (err) {
31
+ if (options.filename) {
32
+ err.message = "In " + options.filename + ", " + err.message;
33
+ }
34
+ throw err;
35
+ }
36
+ };
37
+ exports.tokens = function(code, options) {
38
+ return lexer.tokenize(code, options);
39
+ };
40
+ exports.nodes = function(source, options) {
41
+ if (typeof source === 'string') {
42
+ return parser.parse(lexer.tokenize(source, options));
43
+ } else {
44
+ return parser.parse(source);
45
+ }
46
+ };
47
+ exports.run = function(code, options) {
48
+ var Module, root;
49
+ root = module;
50
+ while (root.parent) {
51
+ root = root.parent;
52
+ }
53
+ root.filename = process.argv[1] = options.filename ? fs.realpathSync(options.filename) : '.';
54
+ if (root.moduleCache) {
55
+ root.moduleCache = {};
56
+ }
57
+ if (process.binding('natives').module) {
58
+ Module = require('module').Module;
59
+ root.paths = Module._nodeModulePaths(path.dirname(options.filename));
60
+ }
61
+ if (path.extname(root.filename) !== '.coffee' || require.extensions) {
62
+ return root._compile(compile(code, options), root.filename);
63
+ } else {
64
+ return root._compile(code, root.filename);
65
+ }
66
+ };
67
+ exports.eval = function(code, options) {
68
+ var g, js, sandbox;
69
+ if (options == null) {
70
+ options = {};
71
+ }
72
+ sandbox = options.sandbox;
73
+ if (!sandbox) {
74
+ sandbox = {
75
+ require: require,
76
+ module: {
77
+ exports: {}
78
+ }
79
+ };
80
+ for (g in global) {
81
+ sandbox[g] = global[g];
82
+ }
83
+ sandbox.global = sandbox;
84
+ sandbox.global.global = sandbox.global.root = sandbox.global.GLOBAL = sandbox;
85
+ }
86
+ sandbox.__filename = options.filename || 'eval';
87
+ sandbox.__dirname = path.dirname(sandbox.__filename);
88
+ js = compile("_=(" + (code.trim()) + ")", options);
89
+ return vm.runInNewContext(js, sandbox, sandbox.__filename);
90
+ };
91
+ lexer = new Lexer;
92
+ parser.lexer = {
93
+ lex: function() {
94
+ var tag, _ref2;
95
+ _ref2 = this.tokens[this.pos++] || [''], tag = _ref2[0], this.yytext = _ref2[1], this.yylineno = _ref2[2];
96
+ return tag;
97
+ },
98
+ setInput: function(tokens) {
99
+ this.tokens = tokens;
100
+ return this.pos = 0;
101
+ },
102
+ upcomingInput: function() {
103
+ return "";
104
+ }
105
+ };
106
+ parser.yy = require('./nodes');
107
+ }).call(this);
@@ -0,0 +1,274 @@
1
+ (function() {
2
+ var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compileScript, compileScripts, compileStdio, contents, exec, forkNode, fs, helpers, lint, loadRequires, optionParser, optparse, opts, parseOptions, path, printLine, printTokens, printWarn, sources, spawn, usage, version, watch, writeJs, _ref;
3
+ fs = require('fs');
4
+ path = require('path');
5
+ helpers = require('./helpers');
6
+ optparse = require('./optparse');
7
+ CoffeeScript = require('./coffee-script');
8
+ _ref = require('child_process'), spawn = _ref.spawn, exec = _ref.exec;
9
+ EventEmitter = require('events').EventEmitter;
10
+ helpers.extend(CoffeeScript, new EventEmitter);
11
+ printLine = function(line) {
12
+ return process.stdout.write(line + '\n');
13
+ };
14
+ printWarn = function(line) {
15
+ return process.binding('stdio').writeError(line + '\n');
16
+ };
17
+ BANNER = 'Usage: coffee [options] path/to/script.coffee';
18
+ SWITCHES = [['-c', '--compile', 'compile to JavaScript and save as .js files'], ['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-o', '--output [DIR]', 'set the directory for compiled JavaScript'], ['-j', '--join [FILE]', 'concatenate the scripts before compiling'], ['-w', '--watch', 'watch scripts for changes, and recompile'], ['-p', '--print', 'print the compiled JavaScript to stdout'], ['-l', '--lint', 'pipe the compiled JavaScript through JSLint'], ['-s', '--stdio', 'listen for and compile scripts over stdio'], ['-e', '--eval', 'compile a string from the command line'], ['-r', '--require [FILE*]', 'require a library before executing your script'], ['-b', '--bare', 'compile without the top-level function wrapper'], ['-t', '--tokens', 'print the tokens that the lexer produces'], ['-n', '--nodes', 'print the parse tree that Jison produces'], ['--nodejs [ARGS]', 'pass options through to the "node" binary'], ['-v', '--version', 'display CoffeeScript version'], ['-h', '--help', 'display this help message']];
19
+ opts = {};
20
+ sources = [];
21
+ contents = [];
22
+ optionParser = null;
23
+ exports.run = function() {
24
+ parseOptions();
25
+ if (opts.nodejs) {
26
+ return forkNode();
27
+ }
28
+ if (opts.help) {
29
+ return usage();
30
+ }
31
+ if (opts.version) {
32
+ return version();
33
+ }
34
+ if (opts.require) {
35
+ loadRequires();
36
+ }
37
+ if (opts.interactive) {
38
+ return require('./repl');
39
+ }
40
+ if (opts.stdio) {
41
+ return compileStdio();
42
+ }
43
+ if (opts.eval) {
44
+ return compileScript(null, sources[0]);
45
+ }
46
+ if (!sources.length) {
47
+ return require('./repl');
48
+ }
49
+ if (opts.run) {
50
+ opts.literals = sources.splice(1).concat(opts.literals);
51
+ }
52
+ process.ARGV = process.argv = process.argv.slice(0, 2).concat(opts.literals);
53
+ process.argv[0] = 'coffee';
54
+ process.execPath = process.mainModule.filename;
55
+ return compileScripts();
56
+ };
57
+ compileScripts = function() {
58
+ var base, compile, source, _i, _len, _results;
59
+ _results = [];
60
+ for (_i = 0, _len = sources.length; _i < _len; _i++) {
61
+ source = sources[_i];
62
+ base = path.join(source);
63
+ compile = function(source, topLevel) {
64
+ return path.exists(source, function(exists) {
65
+ if (topLevel && !exists) {
66
+ throw new Error("File not found: " + source);
67
+ }
68
+ return fs.stat(source, function(err, stats) {
69
+ if (err) {
70
+ throw err;
71
+ }
72
+ if (stats.isDirectory()) {
73
+ return fs.readdir(source, function(err, files) {
74
+ var file, _j, _len2, _results2;
75
+ _results2 = [];
76
+ for (_j = 0, _len2 = files.length; _j < _len2; _j++) {
77
+ file = files[_j];
78
+ _results2.push(compile(path.join(source, file)));
79
+ }
80
+ return _results2;
81
+ });
82
+ } else if (topLevel || path.extname(source) === '.coffee') {
83
+ fs.readFile(source, function(err, code) {
84
+ if (opts.join) {
85
+ contents[sources.indexOf(source)] = code.toString();
86
+ if (helpers.compact(contents).length > 0) {
87
+ return compileJoin();
88
+ }
89
+ } else {
90
+ return compileScript(source, code.toString(), base);
91
+ }
92
+ });
93
+ if (opts.watch && !opts.join) {
94
+ return watch(source, base);
95
+ }
96
+ }
97
+ });
98
+ });
99
+ };
100
+ _results.push(compile(source, true));
101
+ }
102
+ return _results;
103
+ };
104
+ compileScript = function(file, input, base) {
105
+ var o, options, t, task;
106
+ o = opts;
107
+ options = compileOptions(file);
108
+ try {
109
+ t = task = {
110
+ file: file,
111
+ input: input,
112
+ options: options
113
+ };
114
+ CoffeeScript.emit('compile', task);
115
+ if (o.tokens) {
116
+ return printTokens(CoffeeScript.tokens(t.input));
117
+ } else if (o.nodes) {
118
+ return printLine(CoffeeScript.nodes(t.input).toString().trim());
119
+ } else if (o.run) {
120
+ return CoffeeScript.run(t.input, t.options);
121
+ } else {
122
+ t.output = CoffeeScript.compile(t.input, t.options);
123
+ CoffeeScript.emit('success', task);
124
+ if (o.print) {
125
+ return printLine(t.output.trim());
126
+ } else if (o.compile) {
127
+ return writeJs(t.file, t.output, base);
128
+ } else if (o.lint) {
129
+ return lint(t.file, t.output);
130
+ }
131
+ }
132
+ } catch (err) {
133
+ CoffeeScript.emit('failure', err, task);
134
+ if (CoffeeScript.listeners('failure').length) {
135
+ return;
136
+ }
137
+ if (o.watch) {
138
+ return printLine(err.message);
139
+ }
140
+ printWarn(err.stack);
141
+ return process.exit(1);
142
+ }
143
+ };
144
+ compileStdio = function() {
145
+ var code, stdin;
146
+ code = '';
147
+ stdin = process.openStdin();
148
+ stdin.on('data', function(buffer) {
149
+ if (buffer) {
150
+ return code += buffer.toString();
151
+ }
152
+ });
153
+ return stdin.on('end', function() {
154
+ return compileScript(null, code);
155
+ });
156
+ };
157
+ compileJoin = function() {
158
+ var code;
159
+ code = contents.join('\n');
160
+ return compileScript(opts.join, code, opts.join);
161
+ };
162
+ loadRequires = function() {
163
+ var realFilename, req, _i, _len, _ref2;
164
+ realFilename = module.filename;
165
+ module.filename = '.';
166
+ _ref2 = opts.require;
167
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
168
+ req = _ref2[_i];
169
+ require(req);
170
+ }
171
+ return module.filename = realFilename;
172
+ };
173
+ watch = function(source, base) {
174
+ return fs.watchFile(source, {
175
+ persistent: true,
176
+ interval: 500
177
+ }, function(curr, prev) {
178
+ if (curr.size === prev.size && curr.mtime.getTime() === prev.mtime.getTime()) {
179
+ return;
180
+ }
181
+ return fs.readFile(source, function(err, code) {
182
+ if (err) {
183
+ throw err;
184
+ }
185
+ return compileScript(source, code.toString(), base);
186
+ });
187
+ });
188
+ };
189
+ writeJs = function(source, js, base) {
190
+ var baseDir, compile, dir, filename, jsPath, srcDir;
191
+ filename = path.basename(source, path.extname(source)) + '.js';
192
+ srcDir = path.dirname(source);
193
+ baseDir = base === '.' ? srcDir : srcDir.substring(base.length);
194
+ dir = opts.output ? path.join(opts.output, baseDir) : srcDir;
195
+ jsPath = path.join(dir, filename);
196
+ compile = function() {
197
+ if (js.length <= 0) {
198
+ js = ' ';
199
+ }
200
+ return fs.writeFile(jsPath, js, function(err) {
201
+ if (err) {
202
+ return printLine(err.message);
203
+ } else if (opts.compile && opts.watch) {
204
+ return console.log("" + ((new Date).toLocaleTimeString()) + " - compiled " + source);
205
+ }
206
+ });
207
+ };
208
+ return path.exists(dir, function(exists) {
209
+ if (exists) {
210
+ return compile();
211
+ } else {
212
+ return exec("mkdir -p " + dir, compile);
213
+ }
214
+ });
215
+ };
216
+ lint = function(file, js) {
217
+ var conf, jsl, printIt;
218
+ printIt = function(buffer) {
219
+ return printLine(file + ':\t' + buffer.toString().trim());
220
+ };
221
+ conf = __dirname + '/../extras/jsl.conf';
222
+ jsl = spawn('jsl', ['-nologo', '-stdin', '-conf', conf]);
223
+ jsl.stdout.on('data', printIt);
224
+ jsl.stderr.on('data', printIt);
225
+ jsl.stdin.write(js);
226
+ return jsl.stdin.end();
227
+ };
228
+ printTokens = function(tokens) {
229
+ var strings, tag, token, value;
230
+ strings = (function() {
231
+ var _i, _len, _ref2, _results;
232
+ _results = [];
233
+ for (_i = 0, _len = tokens.length; _i < _len; _i++) {
234
+ token = tokens[_i];
235
+ _ref2 = [token[0], token[1].toString().replace(/\n/, '\\n')], tag = _ref2[0], value = _ref2[1];
236
+ _results.push("[" + tag + " " + value + "]");
237
+ }
238
+ return _results;
239
+ })();
240
+ return printLine(strings.join(' '));
241
+ };
242
+ parseOptions = function() {
243
+ var o;
244
+ optionParser = new optparse.OptionParser(SWITCHES, BANNER);
245
+ o = opts = optionParser.parse(process.argv.slice(2));
246
+ o.compile || (o.compile = !!o.output);
247
+ o.run = !(o.compile || o.print || o.lint);
248
+ o.print = !!(o.print || (o.eval || o.stdio && o.compile));
249
+ return sources = o.arguments;
250
+ };
251
+ compileOptions = function(filename) {
252
+ return {
253
+ filename: filename,
254
+ bare: opts.bare
255
+ };
256
+ };
257
+ forkNode = function() {
258
+ var args, nodeArgs;
259
+ nodeArgs = opts.nodejs.split(/\s+/);
260
+ args = process.argv.slice(1);
261
+ args.splice(args.indexOf('--nodejs'), 2);
262
+ return spawn(process.execPath, nodeArgs.concat(args), {
263
+ cwd: process.cwd(),
264
+ env: process.env,
265
+ customFds: [0, 1, 2]
266
+ });
267
+ };
268
+ usage = function() {
269
+ return printLine((new optparse.OptionParser(SWITCHES, BANNER)).help());
270
+ };
271
+ version = function() {
272
+ return printLine("CoffeeScript version " + CoffeeScript.VERSION);
273
+ };
274
+ }).call(this);