gitbook-start-github-rafadanipedro
Version:
Paquete de node para generar un gitbook y todo lo necesario en GitHub
47 lines (39 loc) • 1.66 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
exports.default = function () {
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
var spawn, ssh, resultado;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
spawn = require('child_process').spawn;
ssh = spawn('ssh', ['-T', 'git@github.com']);
_context.next = 4;
return new Promise(function (res, rej) {
var solucion = '';
ssh.stderr.on('data', function (data) {
solucion += data.toString();
});
ssh.on('close', function (code) {
res(solucion);
});
});
case 4:
resultado = _context.sent;
return _context.abrupt('return', resultado.match(/Hi (.+)!/)[1]);
case 6:
case 'end':
return _context.stop();
}
}
}, _callee, this);
}));
function getGithubUsername() {
return _ref.apply(this, arguments);
}
return getGithubUsername;
}();