Commit 9420750c authored by Leo Iannacone's avatar Leo Iannacone

Merge branch 'sbuild' into portable

parents b5212a6d 9e3de8c7
debomatic-webui debomatic-webui
=============== ===============
**debomatic-webui** is a web interface for [Deb-o-Matic](https://launchpad.net/debomatic) aims to give to users a simple way to browse logs and to know what's going on debomatic build service providing a real-time packages status. **debomatic-webui** is a web interface for [Deb-o-Matic](http://debomatic.github.io) aims to give to users a simple way to browse logs and to know what's going on debomatic build service providing a real-time packages status.
This interface is built up on [node](http://nodejs.org/) platform and uses intensely [socket.io](http://socket.io/) and [jquery](http://jquery.com/) technologies. This interface is built up on [node](http://nodejs.org/) platform and uses intensely [socket.io](http://socket.io/) and [jquery](http://jquery.com/) technologies.
Whenever you want to leave a suggestion or file a bug report, please open a [new issue](https://github.com/LeoIannacone/debomatic-webui/issues). Whenever you want to leave a suggestion or file a bug report, please open a [new issue](https://github.com/LeoIannacone/debomatic-webui/issues).
......
...@@ -29,9 +29,11 @@ from time import time ...@@ -29,9 +29,11 @@ from time import time
from json import dumps as toJSON from json import dumps as toJSON
from json import load as fileToJSON from json import load as fileToJSON
from collections import defaultdict from collections import defaultdict
from hashlib import md5
class DebomaticModule_JSONLoggerStart: class DebomaticModule_JSONLoggerStart:
def __init__(self): def __init__(self):
self.logger = DebomaticModule_JSONLogger() self.logger = DebomaticModule_JSONLogger()
self.first = True self.first = True
...@@ -44,6 +46,7 @@ class DebomaticModule_JSONLoggerStart: ...@@ -44,6 +46,7 @@ class DebomaticModule_JSONLoggerStart:
class DebomaticModule_JSONLoggerStop: class DebomaticModule_JSONLoggerStop:
def __init__(self): def __init__(self):
self.logger = DebomaticModule_JSONLogger() self.logger = DebomaticModule_JSONLogger()
self.last = True self.last = True
...@@ -64,30 +67,33 @@ class DebomaticModule_JSONLogger: ...@@ -64,30 +67,33 @@ class DebomaticModule_JSONLogger:
def _set_json_logfile_name(self, args): def _set_json_logfile_name(self, args):
"""If debomatic config file has section [jsonlogger] try to get """If debomatic config file has section [jsonlogger] try to get
'jsonfile' option and override the default value.""" 'jsonfile' option and override the default value."""
if 'opts' in args and \ if (args.opts.has_section('jsonlogger') and
args['opts'].has_section('jsonlogger') and \ args.opts.has_option('jsonlogger', 'jsonfile')):
args['opts'].has_option('jsonlogger', 'jsonfile'): self.jsonfile = args.opts.get('jsonlogger', 'jsonfile').strip()
self.jsonfile = args['opts'].get('jsonlogger', 'jsonfile').strip()
def _get_package_json_filename(self, args): def _get_package_json_filename(self, args):
"""Get the path of package JSON file""" """Get the path of package JSON file"""
return '%(directory)s/pool/%(package)s/%(package)s.json' % args return ('%(directory)s/pool/%(package)s/%(package)s.json' %
{'directory': args.directory, 'package': args.package})
def _get_distribution_status(self, args): def _get_distribution_status(self, args, with_success=False):
"""From args to distribution status""" """From args to distribution status"""
status = {} status = {}
status['status'] = args['cmd'] status['status'] = args.action
status['distribution'] = args['distribution'] status['distribution'] = args.distribution
if 'success' in args: if with_success:
status['success'] = args['success'] status['success'] = args.success
return status return status
def _get_package_status(self, args): def _get_package_status(self, args):
"""From args to package status""" """From args to package status"""
status = {} status = {}
for k in ['package', 'distribution', 'uploader']: status['package'] = args.package
if k in args: status['distribution'] = args.distribution
status[k] = args[k] status['uploader'] = args.uploader
if args.uploader != "":
email = args.uploader.lower().encode('utf-8')
status['gravatar'] = md5(email).hexdigest()
return status return status
def _append_json_logfile(self, args, status): def _append_json_logfile(self, args, status):
...@@ -126,11 +132,15 @@ class DebomaticModule_JSONLogger: ...@@ -126,11 +132,15 @@ class DebomaticModule_JSONLogger:
num /= 1024.0 num /= 1024.0
def pre_chroot(self, args): def pre_chroot(self, args):
if args.action is None:
return
distribution = self._get_distribution_status(args) distribution = self._get_distribution_status(args)
self._append_json_logfile(args, distribution) self._append_json_logfile(args, distribution)
def post_chroot(self, args): def post_chroot(self, args):
distribution = self._get_distribution_status(args) if args.action is None:
return
distribution = self._get_distribution_status(args, with_success=True)
self._append_json_logfile(args, distribution) self._append_json_logfile(args, distribution)
def pre_build(self, args): def pre_build(self, args):
...@@ -145,18 +155,19 @@ class DebomaticModule_JSONLogger: ...@@ -145,18 +155,19 @@ class DebomaticModule_JSONLogger:
def post_build(self, args): def post_build(self, args):
status = self._get_package_status(args) status = self._get_package_status(args)
status['status'] = 'build' status['status'] = 'build'
status['success'] = args['success'] status['success'] = args.success
status['files'] = {} status['files'] = {}
resultdir = os.path.join(args['directory'], 'pool', args['package']) resultdir = os.path.join(args.directory, 'pool', args.package)
for filename in os.listdir(resultdir): for filename in os.listdir(resultdir):
if filename.endswith('.json'): if filename.endswith('.json'):
continue continue
full_path = os.path.join(resultdir, filename) full_path = os.path.join(resultdir, filename)
info = {} info = {}
info['size'] = self._get_human_size(os.path.getsize(full_path)) info['size'] = self._get_human_size(os.path.getsize(full_path))
tag = LogParser(full_path).parse() tag, level = LogParser(full_path).parse()
if tag: if tag:
info['tags'] = tag info['tags'] = tag
info['level'] = level
status['files'][filename] = info status['files'][filename] = info
self._write_package_json(args, status) self._write_package_json(args, status)
status.pop('files', None) status.pop('files', None)
...@@ -165,6 +176,7 @@ class DebomaticModule_JSONLogger: ...@@ -165,6 +176,7 @@ class DebomaticModule_JSONLogger:
# Parser for log files # Parser for log files
class LogParser(): class LogParser():
def __init__(self, file_path): def __init__(self, file_path):
self.file = file_path self.file = file_path
self.basename = os.path.basename(file_path) self.basename = os.path.basename(file_path)
...@@ -173,16 +185,18 @@ class LogParser(): ...@@ -173,16 +185,18 @@ class LogParser():
def parse(self): def parse(self):
if not os.path.isfile(self.file): if not os.path.isfile(self.file):
return None return None
result = None tag = None
# level can be: info, warning, danger
level = "info" # by default
if self.extension == 'lintian': if self.extension == 'lintian':
result = self.parse_lintian() tag, level = self.parse_lintian()
elif self.extension == 'autopkgtest': elif self.extension == 'autopkgtest':
result = self.parse_autopkgtest() tag, level = self.parse_autopkgtest()
elif self.extension == 'piuparts': elif self.extension == 'piuparts':
result = self.parse_piuparts() tag, level = self.parse_piuparts()
elif self.extension == 'blhc': elif self.extension == 'blhc':
result = self.parse_blhc() tag, level = self.parse_blhc()
return result return tag, level
def parse_lintian(self): def parse_lintian(self):
tags = defaultdict(int) tags = defaultdict(int)
...@@ -190,7 +204,13 @@ class LogParser(): ...@@ -190,7 +204,13 @@ class LogParser():
for line in fd: for line in fd:
if len(line) >= 2 and line[0] != 'N' and line[1] == ':': if len(line) >= 2 and line[0] != 'N' and line[1] == ':':
tags[line[0]] += 1 tags[line[0]] += 1
return self._from_tags_to_result(tags) tags = self._from_tags_to_result(tags)
level = "info"
if 'E' in tags:
level = "danger"
elif 'W' in tags:
level = "warning"
return tags, level
def parse_autopkgtest(self): def parse_autopkgtest(self):
tags = defaultdict(int) tags = defaultdict(int)
...@@ -211,14 +231,14 @@ class LogParser(): ...@@ -211,14 +231,14 @@ class LogParser():
tags[info[0]] += 1 tags[info[0]] += 1
elif found and line == '\n': elif found and line == '\n':
break break
return self._from_tags_to_result(tags) return self._from_tags_to_result(tags), 'danger'
def parse_piuparts(self): def parse_piuparts(self):
with open(self.file, 'r') as fd: with open(self.file, 'r') as fd:
lines = fd.readlines() lines = fd.readlines()
if len(lines) == 0 or lines[-1].find('ERROR:') >= 0: if len(lines) == 0 or lines[-1].find('ERROR:') >= 0:
return 'E' return 'E', 'danger'
return None return None, None
def parse_blhc(self): def parse_blhc(self):
tags = defaultdict(int) tags = defaultdict(int)
...@@ -229,7 +249,7 @@ class LogParser(): ...@@ -229,7 +249,7 @@ class LogParser():
continue continue
tag = info[0].replace('FLAGS', '') tag = info[0].replace('FLAGS', '')
tags[tag] += 1 tags[tag] += 1
return ' '.join(sorted(list(tags.keys()))) return ' '.join(sorted(list(tags.keys()))), 'warning'
def _from_tags_to_result(self, tags): def _from_tags_to_result(self, tags):
keys = sorted(list(tags.keys())) keys = sorted(list(tags.keys()))
......
...@@ -7,6 +7,7 @@ io = require("socket.io")(server) ...@@ -7,6 +7,7 @@ io = require("socket.io")(server)
serve_static = require("serve-static") serve_static = require("serve-static")
serve_index = require("serve-index") serve_index = require("serve-index")
compression = require("compression")
errorhandler = require("errorhandler") errorhandler = require("errorhandler")
routes = require("../routes") routes = require("../routes")
...@@ -24,6 +25,9 @@ if env is "development" ...@@ -24,6 +25,9 @@ if env is "development"
else else
app.use(errorhandler()) app.use(errorhandler())
# use compression by default
app.use(compression())
# the views # the views
app.set("views", __dirname + "/../views") app.set("views", __dirname + "/../views")
app.set("view engine", "ejs") app.set("view engine", "ejs")
...@@ -66,6 +70,15 @@ if config.routes.debomatic ...@@ -66,6 +70,15 @@ if config.routes.debomatic
res.set('Content-Type', 'text/plain') res.set('Content-Type', 'text/plain')
next() next()
# always download log files and some source files, like .dsc and .changes ones
app.all config.routes.debomatic + '/:distribution/pool/:package/:file', (req, res, next) ->
type = utils.file_type(req.params.file)
ext = req.params.file.split('.').pop()
if type is "log" or ext in ["changes", "dsc"]
res.set('Content-Type', 'text/plain')
res.set('Content-Disposition', 'attachment; filename=' + req.params.file)
next()
app.use(config.routes.debomatic, serve_static(config.debomatic.path)) app.use(config.routes.debomatic, serve_static(config.debomatic.path))
app.use(config.routes.debomatic, serve_index(config.debomatic.path, app.use(config.routes.debomatic, serve_index(config.debomatic.path,
{view: "details", icons: true})) {view: "details", icons: true}))
...@@ -73,9 +86,6 @@ if config.routes.debomatic ...@@ -73,9 +86,6 @@ if config.routes.debomatic
# serve stylesheet-javascript # serve stylesheet-javascript
app.use(serve_static(__dirname + "/../public")) app.use(serve_static(__dirname + "/../public"))
# serve dsc files as octet-stream
serve_static.mime.define("application/octet-stream": ["dsc"])
# Listening # Listening
server.listen config.port, config.host, null, (err) -> server.listen config.port, config.host, null, (err) ->
......
...@@ -20,9 +20,10 @@ get_files_list_from_package = (data, callback) -> ...@@ -20,9 +20,10 @@ get_files_list_from_package = (data, callback) ->
config.routes.debomatic) config.routes.debomatic)
file.orig_name = f file.orig_name = f
file.name = f.split("_")[0] file.name = f.split("_")[0]
if file.extension in ["deb", "ddeb", "udeb"] type = utils.file_type(f)
if type is "deb"
data.package.debs.push(file) data.package.debs.push(file)
else if file.extension in ["changes", "dsc"] or f.indexOf('.tar.') > 0 or f.indexOf('.diff.') > 0 else if type is "source"
file.name = f.replace(data.package.orig_name + ".", "") file.name = f.replace(data.package.orig_name + ".", "")
if file.extension is "changes" if file.extension is "changes"
file.name = f.split('_').pop() file.name = f.split('_').pop()
...@@ -73,7 +74,7 @@ class Client ...@@ -73,7 +74,7 @@ class Client
pack.orig_name = p pack.orig_name = p
read_package_status {distribution: data.distribution, package: pack}, (content) => read_package_status {distribution: data.distribution, package: pack}, (content) =>
for attr of content for attr of content
if attr not in ['distribution', 'package', 'status', 'success'] if attr not in ['distribution', 'package', 'status', 'success', 'gravatar']
delete content[attr] delete content[attr]
@socket.emit e.distribution_packages_status, content @socket.emit e.distribution_packages_status, content
data.distribution.packages.push pack data.distribution.packages.push pack
......
...@@ -37,8 +37,8 @@ config.debomatic.jsonfile = "/var/log/debomatic-json.log" ...@@ -37,8 +37,8 @@ config.debomatic.jsonfile = "/var/log/debomatic-json.log"
Web template configuration Web template configuration
Title and description for the header Title and description for the header
### ###
config.web.debomatic.architecture = "amd64" config.web.debomatic.architecture = "system" # or amd64, i386, ...
config.web.title = "Deb-o-Matic " + config.web.debomatic.architecture config.web.title = "Deb-o-Matic"
### ###
Admin email and name to show in the home page. Admin email and name to show in the home page.
...@@ -88,6 +88,7 @@ List of files to not show in webui ...@@ -88,6 +88,7 @@ List of files to not show in webui
config.debomatic.excluded_files = [ config.debomatic.excluded_files = [
"datestamp" "datestamp"
"json" "json"
"build"
] ]
### ###
...@@ -163,6 +164,12 @@ try ...@@ -163,6 +164,12 @@ try
crypto.createHash("sha256") crypto.createHash("sha256")
.update(config.debomatic.path) .update(config.debomatic.path)
.digest("hex") .digest("hex")
if config.web.debomatic.architecture == "system"
check = "dpkg-architecture -qDEB_BUILD_ARCH"
require("child_process").exec check, (error, stdout, stderr) ->
config.web.debomatic.architecture = stdout.trim()
module.exports = config module.exports = config
catch err catch err
......
...@@ -5,6 +5,8 @@ glob = require("glob") ...@@ -5,6 +5,8 @@ glob = require("glob")
Tail = require("tail").Tail Tail = require("tail").Tail
_check_no_backward = (backward_path) -> _check_no_backward = (backward_path) ->
if backward_path is undefined
return false
if typeof backward_path is 'string' if typeof backward_path is 'string'
return backward_path.indexOf("..") < 0 return backward_path.indexOf("..") < 0
return true return true
...@@ -33,7 +35,7 @@ get_distributions = (callback) -> ...@@ -33,7 +35,7 @@ get_distributions = (callback) ->
if err if err
errors_handler "get_distributions", err errors_handler "get_distributions", err
return return
distributions = (dir.split(path.sep)[-2...-1] for dir in directories) distributions = (dir.split(path.sep)[-2...-1].pop() for dir in directories)
callback(distributions) callback(distributions)
get_distribution_pool_path = (data) -> get_distribution_pool_path = (data) ->
...@@ -117,6 +119,14 @@ errors_handler = (from, err, socket) -> ...@@ -117,6 +119,14 @@ errors_handler = (from, err, socket) ->
socket.emit config.events.error, msg if socket socket.emit config.events.error, msg if socket
return return
file_type = (filename) ->
extension = filename.split(".").pop()
if extension in ["deb", "ddeb", "udeb"]
return "deb"
if extension in ["changes", "dsc"] or filename.indexOf('.tar.') > 0 or filename.indexOf('.diff.') > 0
return "source"
return "log"
Tail::watchEvent = (e) -> Tail::watchEvent = (e) ->
_this = this _this = this
if e is "change" if e is "change"
...@@ -152,5 +162,6 @@ module.exports.get_file_path = get_file_path ...@@ -152,5 +162,6 @@ module.exports.get_file_path = get_file_path
module.exports.get_files_list = get_files_list module.exports.get_files_list = get_files_list
module.exports.watch_path_onsocket = watch_path_onsocket module.exports.watch_path_onsocket = watch_path_onsocket
module.exports.errors_handler = errors_handler module.exports.errors_handler = errors_handler
module.exports.file_type = file_type
module.exports.arrayEqual = arrayEqual module.exports.arrayEqual = arrayEqual
module.exports.Tail = Tail module.exports.Tail = Tail
Copyright (c) 2009-2014 Jeremy Ashkenas Copyright (c) 2009-2015 Jeremy Ashkenas
Permission is hereby granted, free of charge, to any person Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation obtaining a copy of this software and associated documentation
......
{
"name": "coffee-script",
"version": "1.9.1",
"main": [
"lib/coffee-script/coffee-script.js"
],
"description": "Unfancy JavaScript",
"keywords": [
"javascript",
"language",
"coffeescript",
"compiler"
],
"devDependencies": {
"uglify-js": "~2.2",
"jison": ">=0.2.0",
"highlight.js": "~8.0.0",
"underscore": "~1.5.2",
"docco": "~0.6.2"
},
"author": {
"name": "Jeremy Ashkenas"
},
"ignore": [
"test"
]
}
// Generated by CoffeeScript 1.8.0 // Generated by CoffeeScript 1.9.1
(function() { (function() {
var CoffeeScript, compile, runScripts, var CoffeeScript, compile, runScripts,
__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; }; 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; };
CoffeeScript = require('./coffee-script'); CoffeeScript = require('./coffee-script');
...@@ -34,14 +34,14 @@ ...@@ -34,14 +34,14 @@
if ((typeof btoa !== "undefined" && btoa !== null) && (typeof JSON !== "undefined" && JSON !== null) && (typeof unescape !== "undefined" && unescape !== null) && (typeof encodeURIComponent !== "undefined" && encodeURIComponent !== null)) { if ((typeof btoa !== "undefined" && btoa !== null) && (typeof JSON !== "undefined" && JSON !== null) && (typeof unescape !== "undefined" && unescape !== null) && (typeof encodeURIComponent !== "undefined" && encodeURIComponent !== null)) {
compile = function(code, options) { compile = function(code, options) {
var js, v3SourceMap, _ref; var js, ref, v3SourceMap;
if (options == null) { if (options == null) {
options = {}; options = {};
} }
options.sourceMap = true; options.sourceMap = true;
options.inline = true; options.inline = true;
_ref = CoffeeScript.compile(code, options), js = _ref.js, v3SourceMap = _ref.v3SourceMap; ref = CoffeeScript.compile(code, options), js = ref.js, v3SourceMap = ref.v3SourceMap;
return "" + js + "\n//# sourceMappingURL=data:application/json;base64," + (btoa(unescape(encodeURIComponent(v3SourceMap)))) + "\n//# sourceURL=coffeescript"; return js + "\n//# sourceMappingURL=data:application/json;base64," + (btoa(unescape(encodeURIComponent(v3SourceMap)))) + "\n//# sourceURL=coffeescript";
}; };
} }
...@@ -60,9 +60,9 @@ ...@@ -60,9 +60,9 @@
xhr.overrideMimeType('text/plain'); xhr.overrideMimeType('text/plain');
} }
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
var param, _ref; var param, ref;
if (xhr.readyState === 4) { if (xhr.readyState === 4) {
if ((_ref = xhr.status) === 0 || _ref === 200) { if ((ref = xhr.status) === 0 || ref === 200) {
param = [xhr.responseText, options]; param = [xhr.responseText, options];
if (!hold) { if (!hold) {
CoffeeScript.run.apply(CoffeeScript, param); CoffeeScript.run.apply(CoffeeScript, param);
...@@ -79,19 +79,19 @@ ...@@ -79,19 +79,19 @@
}; };
runScripts = function() { runScripts = function() {
var coffees, coffeetypes, execute, i, index, s, script, scripts, _fn, _i, _len; var coffees, coffeetypes, execute, fn, i, index, j, len, s, script, scripts;
scripts = window.document.getElementsByTagName('script'); scripts = window.document.getElementsByTagName('script');
coffeetypes = ['text/coffeescript', 'text/literate-coffeescript']; coffeetypes = ['text/coffeescript', 'text/literate-coffeescript'];
coffees = (function() { coffees = (function() {
var _i, _len, _ref, _results; var j, len, ref, results;
_results = []; results = [];
for (_i = 0, _len = scripts.length; _i < _len; _i++) { for (j = 0, len = scripts.length; j < len; j++) {
s = scripts[_i]; s = scripts[j];
if (_ref = s.type, __indexOf.call(coffeetypes, _ref) >= 0) { if (ref = s.type, indexOf.call(coffeetypes, ref) >= 0) {
_results.push(s); results.push(s);
} }
} }
return _results; return results;
})(); })();
index = 0; index = 0;
execute = function() { execute = function() {
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
return execute(); return execute();
} }
}; };
_fn = function(script, i) { fn = function(script, i) {
var options; var options;
options = { options = {
literate: script.type === coffeetypes[1] literate: script.type === coffeetypes[1]
...@@ -118,9 +118,9 @@ ...@@ -118,9 +118,9 @@
return coffees[i] = [script.innerHTML, options]; return coffees[i] = [script.innerHTML, options];
} }
}; };
for (i = _i = 0, _len = coffees.length; _i < _len; i = ++_i) { for (i = j = 0, len = coffees.length; j < len; i = ++j) {
script = coffees[i]; script = coffees[i];
_fn(script, i); fn(script, i);
} }
return execute(); return execute();
}; };
......
// Generated by CoffeeScript 1.8.0 // Generated by CoffeeScript 1.9.1
(function() { (function() {
var CoffeeScript, cakefileDirectory, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks; var CoffeeScript, cakefileDirectory, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;
...@@ -24,9 +24,9 @@ ...@@ -24,9 +24,9 @@
helpers.extend(global, { helpers.extend(global, {
task: function(name, description, action) { task: function(name, description, action) {
var _ref; var ref;
if (!action) { if (!action) {
_ref = [description, action], action = _ref[0], description = _ref[1]; ref = [description, action], action = ref[0], description = ref[1];
} }
return tasks[name] = { return tasks[name] = {
name: name, name: name,
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
}); });
exports.run = function() { exports.run = function() {
var arg, args, e, _i, _len, _ref, _results; var arg, args, e, i, len, ref, results;
global.__originalDirname = fs.realpathSync('.'); global.__originalDirname = fs.realpathSync('.');
process.chdir(cakefileDirectory(__originalDirname)); process.chdir(cakefileDirectory(__originalDirname));
args = process.argv.slice(2); args = process.argv.slice(2);
...@@ -63,20 +63,20 @@ ...@@ -63,20 +63,20 @@
e = _error; e = _error;
return fatalError("" + e); return fatalError("" + e);
} }
_ref = options["arguments"]; ref = options["arguments"];
_results = []; results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (i = 0, len = ref.length; i < len; i++) {
arg = _ref[_i]; arg = ref[i];
_results.push(invoke(arg)); results.push(invoke(arg));
} }
return _results; return results;
}; };
printTasks = function() { printTasks = function() {
var cakefilePath, desc, name, relative, spaces, task; var cakefilePath, desc, name, relative, spaces, task;
relative = path.relative || path.resolve; relative = path.relative || path.resolve;
cakefilePath = path.join(relative(__originalDirname, process.cwd()), 'Cakefile'); cakefilePath = path.join(relative(__originalDirname, process.cwd()), 'Cakefile');
console.log("" + cakefilePath + " defines the following tasks:\n"); console.log(cakefilePath + " defines the following tasks:\n");
for (name in tasks) { for (name in tasks) {
task = tasks[name]; task = tasks[name];
spaces = 20 - name.length; spaces = 20 - name.length;
......
// Generated by CoffeeScript 1.8.0 // Generated by CoffeeScript 1.9.1
(function() { (function() {
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, var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, findDirectoryIndex, forkNode, fs, helpers, hidden, joinTimeout, jsToSources, mkdirp, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, ref, removeSource, removeSourceDir, silentUnlink, sourceCode, sources, spawn, timeLog, usage, useWinPathSep, version, wait, watch, watchDir, watchedDirs, writeJs,
__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; }; 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; };
fs = require('fs'); fs = require('fs');
...@@ -13,9 +13,7 @@ ...@@ -13,9 +13,7 @@
CoffeeScript = require('./coffee-script'); CoffeeScript = require('./coffee-script');
mkdirp = require('mkdirp'); ref = require('child_process'), spawn = ref.spawn, exec = ref.exec;
_ref = require('child_process'), spawn = _ref.spawn, exec = _ref.exec;
EventEmitter = require('events').EventEmitter; EventEmitter = require('events').EventEmitter;
...@@ -51,8 +49,10 @@ ...@@ -51,8 +49,10 @@
optionParser = null; optionParser = null;
jsToSources = {};
exports.run = function() { exports.run = function() {
var literals, replCliOpts, source, _i, _len, _ref1, _results; var i, len, literals, ref1, replCliOpts, results, source;
parseOptions(); parseOptions();
replCliOpts = { replCliOpts = {
useGlobal: true useGlobal: true
...@@ -88,19 +88,19 @@ ...@@ -88,19 +88,19 @@
opts.join = path.resolve(opts.join); opts.join = path.resolve(opts.join);
console.error('\nThe --join option is deprecated and will be removed in a future version.\n\nIf for some reason it\'s necessary to share local variables between files,\nreplace...\n\n $ coffee --compile --join bundle.js -- a.coffee b.coffee c.coffee\n\nwith...\n\n $ cat a.coffee b.coffee c.coffee | coffee --compile --stdio > bundle.js\n'); console.error('\nThe --join option is deprecated and will be removed in a future version.\n\nIf for some reason it\'s necessary to share local variables between files,\nreplace...\n\n $ coffee --compile --join bundle.js -- a.coffee b.coffee c.coffee\n\nwith...\n\n $ cat a.coffee b.coffee c.coffee | coffee --compile --stdio > bundle.js\n');
} }
_ref1 = opts["arguments"]; ref1 = opts["arguments"];
_results = []; results = [];
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { for (i = 0, len = ref1.length; i < len; i++) {
source = _ref1[_i]; source = ref1[i];
source = path.resolve(source); source = path.resolve(source);
_results.push(compilePath(source, true, source)); results.push(compilePath(source, true, source));
} }
return _results; return results;
}; };
compilePath = function(source, topLevel, base) { compilePath = function(source, topLevel, base) {
var code, err, file, files, stats, _i, _len, _results; var code, err, file, files, i, len, results, stats;
if (__indexOf.call(sources, source) >= 0 || watchedDirs[source] || !topLevel && (notSources[source] || hidden(source))) { if (indexOf.call(sources, source) >= 0 || watchedDirs[source] || !topLevel && (notSources[source] || hidden(source))) {
return; return;
} }
try { try {
...@@ -135,12 +135,12 @@ ...@@ -135,12 +135,12 @@
throw err; throw err;
} }
} }
_results = []; results = [];
for (_i = 0, _len = files.length; _i < _len; _i++) { for (i = 0, len = files.length; i < len; i++) {
file = files[_i]; file = files[i];
_results.push(compilePath(path.join(source, file), false, base)); results.push(compilePath(path.join(source, file), false, base));
} }
return _results; return results;
} else if (topLevel || helpers.isCoffee(source)) { } else if (topLevel || helpers.isCoffee(source)) {
sources.push(source); sources.push(source);
sourceCode.push(null); sourceCode.push(null);
...@@ -165,10 +165,10 @@ ...@@ -165,10 +165,10 @@
}; };
findDirectoryIndex = function(source) { findDirectoryIndex = function(source) {
var err, ext, index, _i, _len, _ref1; var err, ext, i, index, len, ref1;
_ref1 = CoffeeScript.FILE_EXTENSIONS; ref1 = CoffeeScript.FILE_EXTENSIONS;
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { for (i = 0, len = ref1.length; i < len; i++) {
ext = _ref1[_i]; ext = ref1[i];
index = path.join(source, "index" + ext); index = path.join(source, "index" + ext);
try { try {
if ((fs.statSync(index)).isFile()) { if ((fs.statSync(index)).isFile()) {
...@@ -281,7 +281,7 @@ ...@@ -281,7 +281,7 @@
if (err.code !== 'ENOENT') { if (err.code !== 'ENOENT') {
throw err; throw err;
} }
if (__indexOf.call(sources, source) < 0) { if (indexOf.call(sources, source) < 0) {
return; return;
} }
try { try {
...@@ -348,7 +348,7 @@ ...@@ -348,7 +348,7 @@
}).on('change', function() { }).on('change', function() {
clearTimeout(readdirTimeout); clearTimeout(readdirTimeout);
return readdirTimeout = wait(25, function() { return readdirTimeout = wait(25, function() {
var err, file, files, _i, _len, _results; var err, file, files, i, len, results;
try { try {
files = fs.readdirSync(source); files = fs.readdirSync(source);
} catch (_error) { } catch (_error) {
...@@ -358,12 +358,12 @@ ...@@ -358,12 +358,12 @@
} }
return stopWatcher(); return stopWatcher();
} }
_results = []; results = [];
for (_i = 0, _len = files.length; _i < _len; _i++) { for (i = 0, len = files.length; i < len; i++) {
file = files[_i]; file = files[i];
_results.push(compilePath(path.join(source, file), false, base)); results.push(compilePath(path.join(source, file), false, base));
} }
return _results; return results;
}); });
}); });
}; };
...@@ -383,11 +383,11 @@ ...@@ -383,11 +383,11 @@
}; };
removeSourceDir = function(source, base) { removeSourceDir = function(source, base) {
var file, sourcesChanged, _i, _len; var file, i, len, sourcesChanged;
delete watchedDirs[source]; delete watchedDirs[source];
sourcesChanged = false; sourcesChanged = false;
for (_i = 0, _len = sources.length; _i < _len; _i++) { for (i = 0, len = sources.length; i < len; i++) {
file = sources[_i]; file = sources[i];
if (!(source === path.dirname(file))) { if (!(source === path.dirname(file))) {
continue; continue;
} }
...@@ -412,12 +412,12 @@ ...@@ -412,12 +412,12 @@
}; };
silentUnlink = function(path) { silentUnlink = function(path) {
var err, _ref1; var err, ref1;
try { try {
return fs.unlinkSync(path); return fs.unlinkSync(path);
} catch (_error) { } catch (_error) {
err = _error; err = _error;
if ((_ref1 = err.code) !== 'ENOENT' && _ref1 !== 'EPERM') { if ((ref1 = err.code) !== 'ENOENT' && ref1 !== 'EPERM') {
throw err; throw err;
} }
} }
...@@ -440,6 +440,27 @@ ...@@ -440,6 +440,27 @@
return path.join(dir, basename + extension); return path.join(dir, basename + extension);
}; };
mkdirp = function(dir, fn) {
var mkdirs, mode;
mode = 0x1ff & ~process.umask();
return (mkdirs = function(p, fn) {
return fs.exists(p, function(exists) {
if (exists) {
return fn();
} else {
return mkdirs(path.dirname(p), function() {
return fs.mkdir(p, mode, function(err) {
if (err) {
return fn(err);
}
return fn();
});
});
}
});
})(dir, fn);
};
writeJs = function(base, sourcePath, js, jsPath, generatedSourceMap) { writeJs = function(base, sourcePath, js, jsPath, generatedSourceMap) {
var compile, jsDir, sourceMapPath; var compile, jsDir, sourceMapPath;
if (generatedSourceMap == null) { if (generatedSourceMap == null) {
...@@ -447,13 +468,20 @@ ...@@ -447,13 +468,20 @@
} }
sourceMapPath = outputPath(sourcePath, base, ".js.map"); sourceMapPath = outputPath(sourcePath, base, ".js.map");
jsDir = path.dirname(jsPath); jsDir = path.dirname(jsPath);
if (jsPath in jsToSources) {
printLine("Error: The two following source files have the same output file:");
printLine(" " + jsToSources[jsPath]);
printLine(" " + sourcePath);
process.exit(1);
}
jsToSources[jsPath] = sourcePath;
compile = function() { compile = function() {
if (opts.compile) { if (opts.compile) {
if (js.length <= 0) { if (js.length <= 0) {
js = ' '; js = ' ';
} }
if (generatedSourceMap) { if (generatedSourceMap) {
js = "" + js + "\n//# sourceMappingURL=" + (helpers.baseFileName(sourceMapPath, false, useWinPathSep)) + "\n"; js = js + "\n//# sourceMappingURL=" + (helpers.baseFileName(sourceMapPath, false, useWinPathSep)) + "\n";
} }
fs.writeFile(jsPath, js, function(err) { fs.writeFile(jsPath, js, function(err) {
if (err) { if (err) {
...@@ -487,21 +515,21 @@ ...@@ -487,21 +515,21 @@
}; };
timeLog = function(message) { timeLog = function(message) {
return console.log("" + ((new Date).toLocaleTimeString()) + " - " + message); return console.log(((new Date).toLocaleTimeString()) + " - " + message);
}; };
printTokens = function(tokens) { printTokens = function(tokens) {
var strings, tag, token, value; var strings, tag, token, value;
strings = (function() { strings = (function() {
var _i, _len, _results; var i, len, results;
_results = []; results = [];
for (_i = 0, _len = tokens.length; _i < _len; _i++) { for (i = 0, len = tokens.length; i < len; i++) {
token = tokens[_i]; token = tokens[i];
tag = token[0]; tag = token[0];
value = token[1].toString().replace(/\n/, '\\n'); value = token[1].toString().replace(/\n/, '\\n');
_results.push("[" + tag + " " + value + "]"); results.push("[" + tag + " " + value + "]");
} }
return _results; return results;
})(); })();
return printLine(strings.join(' ')); return printLine(strings.join(' '));
}; };
......
// Generated by CoffeeScript 1.8.0 // Generated by CoffeeScript 1.9.1
(function() { (function() {
var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap; var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap;
...@@ -63,16 +63,26 @@ ...@@ -63,16 +63,26 @@
AlphaNumeric: [ AlphaNumeric: [
o('NUMBER', function() { o('NUMBER', function() {
return new Literal($1); return new Literal($1);
}), o('STRING', function() { }), o('String')
],
String: [
o('STRING', function() {
return new Literal($1);
}), o('STRING_START Body STRING_END', function() {
return new Parens($2);
})
],
Regex: [
o('REGEX', function() {
return new Literal($1); return new Literal($1);
}), o('REGEX_START Invocation REGEX_END', function() {
return $2;
}) })
], ],
Literal: [ Literal: [
o('AlphaNumeric'), o('JS', function() { o('AlphaNumeric'), o('JS', function() {
return new Literal($1); return new Literal($1);
}), o('REGEX', function() { }), o('Regex'), o('DEBUGGER', function() {
return new Literal($1);
}), o('DEBUGGER', function() {
return new Literal($1); return new Literal($1);
}), o('UNDEFINED', function() { }), o('UNDEFINED', function() {
return new Undefined; return new Undefined;
...@@ -421,6 +431,11 @@ ...@@ -421,6 +431,11 @@
return { return {
source: LOC(2)(new Value($2)) source: LOC(2)(new Value($2))
}; };
}), o('FOR Range BY Expression', function() {
return {
source: LOC(2)(new Value($2)),
step: $4
};
}), o('ForStart ForSource', function() { }), o('ForStart ForSource', function() {
$2.own = $1.own; $2.own = $1.own;
$2.name = $1[0]; $2.name = $1[0];
...@@ -552,6 +567,12 @@ ...@@ -552,6 +567,12 @@
return new Op('+', $2); return new Op('+', $2);
}), { }), {
prec: 'UNARY_MATH' prec: 'UNARY_MATH'
}), o('YIELD Statement', function() {
return new Op($1, $2);
}), o('YIELD Expression', function() {
return new Op($1, $2);
}), o('YIELD FROM Expression', function() {
return new Op($1.concat($2), $3);
}), o('-- SimpleAssignable', function() { }), o('-- SimpleAssignable', function() {
return new Op('--', $2); return new Op('--', $2);
}), o('++ SimpleAssignable', function() { }), o('++ SimpleAssignable', function() {
...@@ -594,20 +615,20 @@ ...@@ -594,20 +615,20 @@
] ]
}; };
operators = [['left', '.', '?.', '::', '?::'], ['left', 'CALL_START', 'CALL_END'], ['nonassoc', '++', '--'], ['left', '?'], ['right', 'UNARY'], ['right', '**'], ['right', 'UNARY_MATH'], ['left', 'MATH'], ['left', '+', '-'], ['left', 'SHIFT'], ['left', 'RELATION'], ['left', 'COMPARE'], ['left', 'LOGIC'], ['nonassoc', 'INDENT', 'OUTDENT'], ['right', '=', ':', 'COMPOUND_ASSIGN', 'RETURN', 'THROW', 'EXTENDS'], ['right', 'FORIN', 'FOROF', 'BY', 'WHEN'], ['right', 'IF', 'ELSE', 'FOR', 'WHILE', 'UNTIL', 'LOOP', 'SUPER', 'CLASS'], ['left', 'POST_IF']]; operators = [['left', '.', '?.', '::', '?::'], ['left', 'CALL_START', 'CALL_END'], ['nonassoc', '++', '--'], ['left', '?'], ['right', 'UNARY'], ['right', '**'], ['right', 'UNARY_MATH'], ['left', 'MATH'], ['left', '+', '-'], ['left', 'SHIFT'], ['left', 'RELATION'], ['left', 'COMPARE'], ['left', 'LOGIC'], ['nonassoc', 'INDENT', 'OUTDENT'], ['right', 'YIELD'], ['right', '=', ':', 'COMPOUND_ASSIGN', 'RETURN', 'THROW', 'EXTENDS'], ['right', 'FORIN', 'FOROF', 'BY', 'WHEN'], ['right', 'IF', 'ELSE', 'FOR', 'WHILE', 'UNTIL', 'LOOP', 'SUPER', 'CLASS'], ['left', 'POST_IF']];
tokens = []; tokens = [];
for (name in grammar) { for (name in grammar) {
alternatives = grammar[name]; alternatives = grammar[name];
grammar[name] = (function() { grammar[name] = (function() {
var _i, _j, _len, _len1, _ref, _results; var i, j, len, len1, ref, results;
_results = []; results = [];
for (_i = 0, _len = alternatives.length; _i < _len; _i++) { for (i = 0, len = alternatives.length; i < len; i++) {
alt = alternatives[_i]; alt = alternatives[i];
_ref = alt[0].split(' '); ref = alt[0].split(' ');
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { for (j = 0, len1 = ref.length; j < len1; j++) {
token = _ref[_j]; token = ref[j];
if (!grammar[token]) { if (!grammar[token]) {
tokens.push(token); tokens.push(token);
} }
...@@ -615,9 +636,9 @@ ...@@ -615,9 +636,9 @@
if (name === 'Root') { if (name === 'Root') {
alt[1] = "return " + alt[1]; alt[1] = "return " + alt[1];
} }
_results.push(alt); results.push(alt);
} }
return _results; return results;
})(); })();
} }
......
// Generated by CoffeeScript 1.8.0 // Generated by CoffeeScript 1.9.1
(function() { (function() {
var buildLocationData, extend, flatten, last, repeat, syntaxErrorToString, _ref; var buildLocationData, extend, flatten, ref, repeat, syntaxErrorToString;
exports.starts = function(string, literal, start) { exports.starts = function(string, literal, start) {
return literal === string.substr(start, literal.length); return literal === string.substr(start, literal.length);
...@@ -26,15 +26,15 @@ ...@@ -26,15 +26,15 @@
}; };
exports.compact = function(array) { exports.compact = function(array) {
var item, _i, _len, _results; var i, item, len1, results;
_results = []; results = [];
for (_i = 0, _len = array.length; _i < _len; _i++) { for (i = 0, len1 = array.length; i < len1; i++) {
item = array[_i]; item = array[i];
if (item) { if (item) {
_results.push(item); results.push(item);
} }
} }
return _results; return results;
}; };
exports.count = function(string, substr) { exports.count = function(string, substr) {
...@@ -63,10 +63,10 @@ ...@@ -63,10 +63,10 @@
}; };
exports.flatten = flatten = function(array) { exports.flatten = flatten = function(array) {
var element, flattened, _i, _len; var element, flattened, i, len1;
flattened = []; flattened = [];
for (_i = 0, _len = array.length; _i < _len; _i++) { for (i = 0, len1 = array.length; i < len1; i++) {
element = array[_i]; element = array[i];
if (element instanceof Array) { if (element instanceof Array) {
flattened = flattened.concat(flatten(element)); flattened = flattened.concat(flatten(element));
} else { } else {
...@@ -83,14 +83,10 @@ ...@@ -83,14 +83,10 @@
return val; return val;
}; };
exports.last = last = function(array, back) { exports.some = (ref = Array.prototype.some) != null ? ref : function(fn) {
return array[array.length - (back || 0) - 1]; var e, i, len1;
}; for (i = 0, len1 = this.length; i < len1; i++) {
e = this[i];
exports.some = (_ref = Array.prototype.some) != null ? _ref : function(fn) {
var e, _i, _len;
for (_i = 0, _len = this.length; _i < _len; _i++) {
e = this[_i];
if (fn(e)) { if (fn(e)) {
return true; return true;
} }
...@@ -102,20 +98,20 @@ ...@@ -102,20 +98,20 @@
var line, lines, maybe_code; var line, lines, maybe_code;
maybe_code = true; maybe_code = true;
lines = (function() { lines = (function() {
var _i, _len, _ref1, _results; var i, len1, ref1, results;
_ref1 = code.split('\n'); ref1 = code.split('\n');
_results = []; results = [];
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { for (i = 0, len1 = ref1.length; i < len1; i++) {
line = _ref1[_i]; line = ref1[i];
if (maybe_code && /^([ ]{4}|[ ]{0,3}\t)/.test(line)) { if (maybe_code && /^([ ]{4}|[ ]{0,3}\t)/.test(line)) {
_results.push(line); results.push(line);
} else if (maybe_code = /^\s*$/.test(line)) { } else if (maybe_code = /^\s*$/.test(line)) {
_results.push(line); results.push(line);
} else { } else {
_results.push('# ' + line); results.push('# ' + line);
} }
} }
return _results; return results;
})(); })();
return lines.join('\n'); return lines.join('\n');
}; };
...@@ -150,7 +146,7 @@ ...@@ -150,7 +146,7 @@
locationData = obj; locationData = obj;
} }
if (locationData) { if (locationData) {
return ("" + (locationData.first_line + 1) + ":" + (locationData.first_column + 1) + "-") + ("" + (locationData.last_line + 1) + ":" + (locationData.last_column + 1)); return ((locationData.first_line + 1) + ":" + (locationData.first_column + 1) + "-") + ((locationData.last_line + 1) + ":" + (locationData.last_column + 1));
} else { } else {
return "No location data"; return "No location data";
} }
...@@ -205,11 +201,11 @@ ...@@ -205,11 +201,11 @@
}; };
syntaxErrorToString = function() { syntaxErrorToString = function() {
var codeLine, colorize, colorsEnabled, end, filename, first_column, first_line, last_column, last_line, marker, start, _ref1, _ref2; var codeLine, colorize, colorsEnabled, end, filename, first_column, first_line, last_column, last_line, marker, ref1, ref2, start;
if (!(this.code && this.location)) { if (!(this.code && this.location)) {
return Error.prototype.toString.call(this); return Error.prototype.toString.call(this);
} }
_ref1 = this.location, first_line = _ref1.first_line, first_column = _ref1.first_column, last_line = _ref1.last_line, last_column = _ref1.last_column; ref1 = this.location, first_line = ref1.first_line, first_column = ref1.first_column, last_line = ref1.last_line, last_column = ref1.last_column;
if (last_line == null) { if (last_line == null) {
last_line = first_line; last_line = first_line;
} }
...@@ -224,14 +220,14 @@ ...@@ -224,14 +220,14 @@
if (typeof process !== "undefined" && process !== null) { if (typeof process !== "undefined" && process !== null) {
colorsEnabled = process.stdout.isTTY && !process.env.NODE_DISABLE_COLORS; colorsEnabled = process.stdout.isTTY && !process.env.NODE_DISABLE_COLORS;
} }
if ((_ref2 = this.colorful) != null ? _ref2 : colorsEnabled) { if ((ref2 = this.colorful) != null ? ref2 : colorsEnabled) {
colorize = function(str) { colorize = function(str) {
return "\x1B[1;31m" + str + "\x1B[0m"; return "\x1B[1;31m" + str + "\x1B[0m";
}; };
codeLine = codeLine.slice(0, start) + colorize(codeLine.slice(start, end)) + codeLine.slice(end); codeLine = codeLine.slice(0, start) + colorize(codeLine.slice(start, end)) + codeLine.slice(end);
marker = colorize(marker); marker = colorize(marker);
} }
return "" + filename + ":" + (first_line + 1) + ":" + (first_column + 1) + ": error: " + this.message + "\n" + codeLine + "\n" + marker; return filename + ":" + (first_line + 1) + ":" + (first_column + 1) + ": error: " + this.message + "\n" + codeLine + "\n" + marker;
}; };
exports.nameWhitespaceCharacter = function(string) { exports.nameWhitespaceCharacter = function(string) {
......
// Generated by CoffeeScript 1.8.0 // Generated by CoffeeScript 1.9.1
(function() { (function() {
var key, val, _ref; var key, ref, val;
_ref = require('./coffee-script'); ref = require('./coffee-script');
for (key in _ref) { for (key in ref) {
val = _ref[key]; val = ref[key];
exports[key] = val; exports[key] = val;
} }
......
// Generated by CoffeeScript 1.8.0 // Generated by CoffeeScript 1.9.1
(function() { (function() {
var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments, repeat; var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments, repeat;
...@@ -11,14 +11,14 @@ ...@@ -11,14 +11,14 @@
} }
OptionParser.prototype.parse = function(args) { OptionParser.prototype.parse = function(args) {
var arg, i, isOption, matchedRule, options, originalArgs, pos, rule, seenNonOptionArg, skippingArgument, value, _i, _j, _len, _len1, _ref; var arg, i, isOption, j, k, len, len1, matchedRule, options, originalArgs, pos, ref, rule, seenNonOptionArg, skippingArgument, value;
options = { options = {
"arguments": [] "arguments": []
}; };
skippingArgument = false; skippingArgument = false;
originalArgs = args; originalArgs = args;
args = normalizeArguments(args); args = normalizeArguments(args);
for (i = _i = 0, _len = args.length; _i < _len; i = ++_i) { for (i = j = 0, len = args.length; j < len; i = ++j) {
arg = args[i]; arg = args[i];
if (skippingArgument) { if (skippingArgument) {
skippingArgument = false; skippingArgument = false;
...@@ -33,9 +33,9 @@ ...@@ -33,9 +33,9 @@
seenNonOptionArg = options["arguments"].length > 0; seenNonOptionArg = options["arguments"].length > 0;
if (!seenNonOptionArg) { if (!seenNonOptionArg) {
matchedRule = false; matchedRule = false;
_ref = this.rules; ref = this.rules;
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { for (k = 0, len1 = ref.length; k < len1; k++) {
rule = _ref[_j]; rule = ref[k];
if (rule.shortFlag === arg || rule.longFlag === arg) { if (rule.shortFlag === arg || rule.longFlag === arg) {
value = true; value = true;
if (rule.hasArgument) { if (rule.hasArgument) {
...@@ -59,14 +59,14 @@ ...@@ -59,14 +59,14 @@
}; };
OptionParser.prototype.help = function() { OptionParser.prototype.help = function() {
var letPart, lines, rule, spaces, _i, _len, _ref; var j, len, letPart, lines, ref, rule, spaces;
lines = []; lines = [];
if (this.banner) { if (this.banner) {
lines.unshift("" + this.banner + "\n"); lines.unshift(this.banner + "\n");
} }
_ref = this.rules; ref = this.rules;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (j = 0, len = ref.length; j < len; j++) {
rule = _ref[_i]; rule = ref[j];
spaces = 15 - rule.longFlag.length; spaces = 15 - rule.longFlag.length;
spaces = spaces > 0 ? repeat(' ', spaces) : ''; spaces = spaces > 0 ? repeat(' ', spaces) : '';
letPart = rule.shortFlag ? rule.shortFlag + ', ' : ' '; letPart = rule.shortFlag ? rule.shortFlag + ', ' : ' ';
...@@ -88,16 +88,16 @@ ...@@ -88,16 +88,16 @@
OPTIONAL = /\[(\w+(\*?))\]/; OPTIONAL = /\[(\w+(\*?))\]/;
buildRules = function(rules) { buildRules = function(rules) {
var tuple, _i, _len, _results; var j, len, results, tuple;
_results = []; results = [];
for (_i = 0, _len = rules.length; _i < _len; _i++) { for (j = 0, len = rules.length; j < len; j++) {
tuple = rules[_i]; tuple = rules[j];
if (tuple.length < 3) { if (tuple.length < 3) {
tuple.unshift(null); tuple.unshift(null);
} }
_results.push(buildRule.apply(null, tuple)); results.push(buildRule.apply(null, tuple));
} }
return _results; return results;
}; };
buildRule = function(shortFlag, longFlag, description, options) { buildRule = function(shortFlag, longFlag, description, options) {
...@@ -118,15 +118,15 @@ ...@@ -118,15 +118,15 @@
}; };
normalizeArguments = function(args) { normalizeArguments = function(args) {
var arg, l, match, result, _i, _j, _len, _len1, _ref; var arg, j, k, l, len, len1, match, ref, result;
args = args.slice(0); args = args.slice(0);
result = []; result = [];
for (_i = 0, _len = args.length; _i < _len; _i++) { for (j = 0, len = args.length; j < len; j++) {
arg = args[_i]; arg = args[j];
if (match = arg.match(MULTI_FLAG)) { if (match = arg.match(MULTI_FLAG)) {
_ref = match[1].split(''); ref = match[1].split('');
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { for (k = 0, len1 = ref.length; k < len1; k++) {
l = _ref[_j]; l = ref[k];
result.push('-' + l); result.push('-' + l);
} }
} else { } else {
......
// Generated by CoffeeScript 1.8.0 // Generated by CoffeeScript 1.9.1
(function() { (function() {
var CoffeeScript, Module, binary, child_process, ext, findExtension, fork, helpers, loadFile, path, _i, _len, _ref; var CoffeeScript, Module, binary, child_process, ext, findExtension, fork, helpers, i, len, loadFile, path, ref;
CoffeeScript = require('./coffee-script'); CoffeeScript = require('./coffee-script');
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
}; };
if (require.extensions) { if (require.extensions) {
_ref = CoffeeScript.FILE_EXTENSIONS; ref = CoffeeScript.FILE_EXTENSIONS;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (i = 0, len = ref.length; i < len; i++) {
ext = _ref[_i]; ext = ref[i];
require.extensions[ext] = loadFile; require.extensions[ext] = loadFile;
} }
Module = require('module'); Module = require('module');
......
// Generated by CoffeeScript 1.8.0 // Generated by CoffeeScript 1.9.1
(function() { (function() {
var CoffeeScript, addHistory, addMultilineHandler, fs, getCommandId, merge, nodeREPL, path, replDefaults, updateSyntaxError, vm, _ref; var CoffeeScript, addHistory, addMultilineHandler, fs, getCommandId, merge, nodeREPL, path, ref, replDefaults, updateSyntaxError, vm;
fs = require('fs'); fs = require('fs');
...@@ -12,23 +12,36 @@ ...@@ -12,23 +12,36 @@
CoffeeScript = require('./coffee-script'); CoffeeScript = require('./coffee-script');
_ref = require('./helpers'), merge = _ref.merge, updateSyntaxError = _ref.updateSyntaxError; ref = require('./helpers'), merge = ref.merge, updateSyntaxError = ref.updateSyntaxError;
replDefaults = { replDefaults = {
prompt: 'coffee> ', prompt: 'coffee> ',
historyFile: process.env.HOME ? path.join(process.env.HOME, '.coffee_history') : void 0, historyFile: process.env.HOME ? path.join(process.env.HOME, '.coffee_history') : void 0,
historyMaxInputSize: 10240, historyMaxInputSize: 10240,
"eval": function(input, context, filename, cb) { "eval": function(input, context, filename, cb) {
var Assign, Block, Literal, Value, ast, err, js, result, _ref1; var Assign, Block, Literal, Value, ast, err, js, ref1, referencedVars, result, token, tokens;
input = input.replace(/\uFF00/g, '\n'); input = input.replace(/\uFF00/g, '\n');
input = input.replace(/^\(([\s\S]*)\n\)$/m, '$1'); input = input.replace(/^\(([\s\S]*)\n\)$/m, '$1');
_ref1 = require('./nodes'), Block = _ref1.Block, Assign = _ref1.Assign, Value = _ref1.Value, Literal = _ref1.Literal; ref1 = require('./nodes'), Block = ref1.Block, Assign = ref1.Assign, Value = ref1.Value, Literal = ref1.Literal;
try { try {
ast = CoffeeScript.nodes(input); tokens = CoffeeScript.tokens(input);
referencedVars = (function() {
var i, len, results;
results = [];
for (i = 0, len = tokens.length; i < len; i++) {
token = tokens[i];
if (token.variable) {
results.push(token[1]);
}
}
return results;
})();
ast = CoffeeScript.nodes(tokens);
ast = new Block([new Assign(new Value(new Literal('_')), ast, '=')]); ast = new Block([new Assign(new Value(new Literal('_')), ast, '=')]);
js = ast.compile({ js = ast.compile({
bare: true, bare: true,
locals: Object.keys(context) locals: Object.keys(context),
referencedVars: referencedVars
}); });
result = context === global ? vm.runInThisContext(js, filename) : vm.runInContext(js, context, filename); result = context === global ? vm.runInThisContext(js, filename) : vm.runInContext(js, context, filename);
return cb(null, result); return cb(null, result);
...@@ -41,9 +54,9 @@ ...@@ -41,9 +54,9 @@
}; };
addMultilineHandler = function(repl) { addMultilineHandler = function(repl) {
var inputStream, multiline, nodeLineListener, origPrompt, outputStream, rli, _ref1; var inputStream, multiline, nodeLineListener, origPrompt, outputStream, ref1, rli;
rli = repl.rli, inputStream = repl.inputStream, outputStream = repl.outputStream; rli = repl.rli, inputStream = repl.inputStream, outputStream = repl.outputStream;
origPrompt = (_ref1 = repl._prompt) != null ? _ref1 : repl.prompt; origPrompt = (ref1 = repl._prompt) != null ? ref1 : repl.prompt;
multiline = { multiline = {
enabled: false, enabled: false,
initialPrompt: origPrompt.replace(/^[^> ]*/, function(x) { initialPrompt: origPrompt.replace(/^[^> ]*/, function(x) {
...@@ -58,7 +71,7 @@ ...@@ -58,7 +71,7 @@
rli.removeListener('line', nodeLineListener); rli.removeListener('line', nodeLineListener);
rli.on('line', function(cmd) { rli.on('line', function(cmd) {
if (multiline.enabled) { if (multiline.enabled) {
multiline.buffer += "" + cmd + "\n"; multiline.buffer += cmd + "\n";
rli.setPrompt(multiline.prompt); rli.setPrompt(multiline.prompt);
rli.prompt(true); rli.prompt(true);
} else { } else {
...@@ -118,7 +131,7 @@ ...@@ -118,7 +131,7 @@
fd = fs.openSync(filename, 'a'); fd = fs.openSync(filename, 'a');
repl.rli.addListener('line', function(code) { repl.rli.addListener('line', function(code) {
if (code && code.length && code !== '.history' && lastLine !== code) { if (code && code.length && code !== '.history' && lastLine !== code) {
fs.write(fd, "" + code + "\n"); fs.write(fd, code + "\n");
return lastLine = code; return lastLine = code;
} }
}); });
...@@ -128,7 +141,7 @@ ...@@ -128,7 +141,7 @@
return repl.commands[getCommandId(repl, 'history')] = { return repl.commands[getCommandId(repl, 'history')] = {
help: 'Show command history', help: 'Show command history',
action: function() { action: function() {
repl.outputStream.write("" + (repl.rli.history.slice(0).reverse().join('\n')) + "\n"); repl.outputStream.write((repl.rli.history.slice(0).reverse().join('\n')) + "\n");
return repl.displayPrompt(); return repl.displayPrompt();
} }
}; };
...@@ -146,13 +159,13 @@ ...@@ -146,13 +159,13 @@
module.exports = { module.exports = {
start: function(opts) { start: function(opts) {
var build, major, minor, repl, _ref1; var build, major, minor, ref1, repl;
if (opts == null) { if (opts == null) {
opts = {}; opts = {};
} }
_ref1 = process.versions.node.split('.').map(function(n) { ref1 = process.versions.node.split('.').map(function(n) {
return parseInt(n); return parseInt(n);
}), major = _ref1[0], minor = _ref1[1], build = _ref1[2]; }), major = ref1[0], minor = ref1[1], build = ref1[2];
if (major === 0 && minor < 8) { if (major === 0 && minor < 8) {
console.warn("Node 0.8.0+ required for CoffeeScript REPL"); console.warn("Node 0.8.0+ required for CoffeeScript REPL");
process.exit(1); process.exit(1);
......
// Generated by CoffeeScript 1.8.0 // Generated by CoffeeScript 1.9.1
(function() { (function() {
var LineMap, SourceMap; var LineMap, SourceMap;
LineMap = (function() { LineMap = (function() {
function LineMap(line) { function LineMap(line1) {
this.line = line; this.line = line1;
this.columns = []; this.columns = [];
} }
LineMap.prototype.add = function(column, _arg, options) { LineMap.prototype.add = function(column, arg, options) {
var sourceColumn, sourceLine; var sourceColumn, sourceLine;
sourceLine = _arg[0], sourceColumn = _arg[1]; sourceLine = arg[0], sourceColumn = arg[1];
if (options == null) { if (options == null) {
options = {}; options = {};
} }
...@@ -45,18 +45,18 @@ ...@@ -45,18 +45,18 @@
} }
SourceMap.prototype.add = function(sourceLocation, generatedLocation, options) { SourceMap.prototype.add = function(sourceLocation, generatedLocation, options) {
var column, line, lineMap, _base; var base, column, line, lineMap;
if (options == null) { if (options == null) {
options = {}; options = {};
} }
line = generatedLocation[0], column = generatedLocation[1]; line = generatedLocation[0], column = generatedLocation[1];
lineMap = ((_base = this.lines)[line] || (_base[line] = new LineMap(line))); lineMap = ((base = this.lines)[line] || (base[line] = new LineMap(line)));
return lineMap.add(column, sourceLocation, options); return lineMap.add(column, sourceLocation, options);
}; };
SourceMap.prototype.sourceLocation = function(_arg) { SourceMap.prototype.sourceLocation = function(arg) {
var column, line, lineMap; var column, line, lineMap;
line = _arg[0], column = _arg[1]; line = arg[0], column = arg[1];
while (!((lineMap = this.lines[line]) || (line <= 0))) { while (!((lineMap = this.lines[line]) || (line <= 0))) {
line--; line--;
} }
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
}; };
SourceMap.prototype.generate = function(options, code) { SourceMap.prototype.generate = function(options, code) {
var buffer, lastColumn, lastSourceColumn, lastSourceLine, lineMap, lineNumber, mapping, needComma, v3, writingline, _i, _j, _len, _len1, _ref, _ref1; var buffer, i, j, lastColumn, lastSourceColumn, lastSourceLine, len, len1, lineMap, lineNumber, mapping, needComma, ref, ref1, v3, writingline;
if (options == null) { if (options == null) {
options = {}; options = {};
} }
...@@ -77,13 +77,13 @@ ...@@ -77,13 +77,13 @@
lastSourceColumn = 0; lastSourceColumn = 0;
needComma = false; needComma = false;
buffer = ""; buffer = "";
_ref = this.lines; ref = this.lines;
for (lineNumber = _i = 0, _len = _ref.length; _i < _len; lineNumber = ++_i) { for (lineNumber = i = 0, len = ref.length; i < len; lineNumber = ++i) {
lineMap = _ref[lineNumber]; lineMap = ref[lineNumber];
if (lineMap) { if (lineMap) {
_ref1 = lineMap.columns; ref1 = lineMap.columns;
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { for (j = 0, len1 = ref1.length; j < len1; j++) {
mapping = _ref1[_j]; mapping = ref1[j];
if (!(mapping)) { if (!(mapping)) {
continue; continue;
} }
......
var mkdirp = require('mkdirp');
mkdirp('/tmp/foo/bar/baz', function (err) {
if (err) console.error(err)
else console.log('pow!')
});
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Copyright 2010 James Halliday (mail@substack.net)
This project is free software released under the MIT/X11 license: The MIT License (MIT)
Copyright (c) 2014 Jonathan Ong me@jongleberry.com
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment