code: function promisify (server) {
    const originalEval = server.eval
  
    server.eval = function (cmd, context, filename, callback) {
      if (cmd.match(/\W*yield\s+/)) {
        cmd = 'co(function* () {' + cmd.replace(/^\s*var\s+/, '') + '})'
      }
  
      originalEval.call(server, cmd, context, filename, function (err, res) {
        if (err || !isPromise(res)) {
          return callback(err, res)
        }
  
        res.then(
          result => callback(null, result),
          callback
        )
      })
    }
  
    return server
  }
docs: source: https://github.com/mvertes/co-shell (with minor adaptations)