@rnv/engine-core
Version:
ReNative Engine Core
59 lines • 2.7 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var core_1 = require("@rnv/core");
var path_1 = tslib_1.__importDefault(require("path"));
var getContext_1 = require("../../../getContext");
var Question = function (data) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var c, _a, gitEnabled, ci, inputs, response;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
c = (0, getContext_1.getContext)();
_a = c.program.opts(), gitEnabled = _a.gitEnabled, ci = _a.ci;
inputs = data.inputs;
inputs.confirmEnableGit = !!gitEnabled;
if (!(gitEnabled === undefined && !ci)) return [3 /*break*/, 2];
return [4 /*yield*/, (0, core_1.inquirerPrompt)({
name: 'gitEnabled',
type: 'confirm',
message: 'Do you want to set-up git in your new project?',
})];
case 1:
response = _b.sent();
inputs.confirmEnableGit = response.gitEnabled;
_b.label = 2;
case 2:
if (!inputs.confirmEnableGit) return [3 /*break*/, 4];
return [4 /*yield*/, configureGit()];
case 3:
_b.sent();
_b.label = 4;
case 4: return [2 /*return*/];
}
});
}); };
var configureGit = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var c, projectPath;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
c = (0, getContext_1.getContext)();
projectPath = c.paths.project.dir;
(0, core_1.logTask)("configureGit:".concat(projectPath));
if (!!(0, core_1.fsExistsSync)(path_1.default.join(projectPath, '.git'))) return [3 /*break*/, 3];
(0, core_1.logInfo)('Your project does not have a git repo. Creating one...DONE');
if (!(0, core_1.commandExistsSync)('git')) return [3 /*break*/, 2];
return [4 /*yield*/, (0, core_1.executeAsync)('git init', { cwd: projectPath })];
case 1:
_a.sent();
return [3 /*break*/, 3];
case 2:
(0, core_1.logWarning)("We tried to create a git repo inside your project but you don't seem to have git installed");
_a.label = 3;
case 3: return [2 /*return*/];
}
});
}); };
exports.default = Question;
//# sourceMappingURL=confirmGit.js.map
;