36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.parseInit = exports.InitSummary = void 0;
|
|
class InitSummary {
|
|
constructor(bare, path, existing, gitDir) {
|
|
this.bare = bare;
|
|
this.path = path;
|
|
this.existing = existing;
|
|
this.gitDir = gitDir;
|
|
}
|
|
}
|
|
exports.InitSummary = InitSummary;
|
|
const initResponseRegex = /^Init.+ repository in (.+)$/;
|
|
const reInitResponseRegex = /^Rein.+ in (.+)$/;
|
|
function parseInit(bare, path, text) {
|
|
const response = String(text).trim();
|
|
let result;
|
|
if ((result = initResponseRegex.exec(response))) {
|
|
return new InitSummary(bare, path, false, result[1]);
|
|
}
|
|
if ((result = reInitResponseRegex.exec(response))) {
|
|
return new InitSummary(bare, path, true, result[1]);
|
|
}
|
|
let gitDir = '';
|
|
const tokens = response.split(' ');
|
|
while (tokens.length) {
|
|
const token = tokens.shift();
|
|
if (token === 'in') {
|
|
gitDir = tokens.join(' ');
|
|
break;
|
|
}
|
|
}
|
|
return new InitSummary(bare, path, /^re/i.test(response), gitDir);
|
|
}
|
|
exports.parseInit = parseInit;
|
|
//# sourceMappingURL=InitSummary.js.map
|