function checkUsage (f) { var _process = process; process = Hash.copy(process); var exit = false; process.exit = function () { exit = true }; process.env = Hash.merge(process.env, { _ : 'node' }); process.argv = [ './usage' ]; var errors = []; var logs = []; console._error = console.error; console.error = function (msg) { errors.push(msg) }; console._log = console.log; console.log = function (msg) { logs.push(msg) }; var result = f(); process = _process; console.error = console._error; console.log = console._log; return { errors : errors, logs : logs, exit : exit, result : result, }; };
app.post('/admin/users/create', function (req, res) { var u = {}; u[req.body.name] = { name : req.body.name }; res.render('pages/admin.html', { locals : locals(req, { users : Hash.merge(users, u) }) }); console.log('TODO: actually create users'); });
db.get(key, function (err, branch) { var b = branch || { channels : [] }; var updated = Hash.merge(b, { channels : b.channels.indexOf(channel) >= 0 ? b.channels : b.channels.concat([ channel ]) , user : where.user, repo : where.repo, name : where.branch, key : key, }); db.set(key, updated); });
function locals (req, vars) { var user = users[req.session.name]; return Hash.merge({ Hash : Hash, user : user, views : views, request : req, tabs : user ? [].concat(user.admin ? [ { path : '/admin', name : 'administer' } ] : []) : [] , }, vars); }
this.getCommits(function (err, branch, meta, commits) { if (err) { //So we know which branch is causing the error err.branch = branch; cb(err, branch); return } if (meta.lastCommit != commits[0].id) { db.set(branch, Hash.merge(meta, { lastCommit : commits[0].id })); if (meta.lastCommit) { cb(null, branch, meta, takeWhile(commits, function (commit) { return commit.id != meta.lastCommit; })); } } });