UNPKG

@rnv/engine-core

Version:
41 lines 2.39 kB
"use strict"; 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 Question = function (data) { return tslib_1.__awaiter(void 0, void 0, void 0, function () { var c, files, cnfTemplatesName, cnfDepVer, ctCnfPath; var _a, _b, _c, _d; return tslib_1.__generator(this, function (_e) { switch (_e.label) { case 0: c = (0, core_1.getContext)(); files = data.files; cnfTemplatesName = '@rnv/config-templates'; cnfDepVer = (_d = (_c = (_b = (_a = files.template.renativeTemplateConfig) === null || _a === void 0 ? void 0 : _a.templateConfig) === null || _b === void 0 ? void 0 : _b.package_json) === null || _c === void 0 ? void 0 : _c.devDependencies) === null || _d === void 0 ? void 0 : _d[cnfTemplatesName]; if (!cnfDepVer) return [3 /*break*/, 2]; // If we find the config-templates package in the devDependencies of the project's package.json, // we will use it as source for engines return [4 /*yield*/, (0, core_1.executeAsync)("".concat((0, core_1.isYarnInstalled)() ? 'yarn' : 'npm', " add ").concat(cnfTemplatesName, "@").concat(cnfDepVer, " --dev"), { cwd: c.paths.project.dir, })]; case 1: // If we find the config-templates package in the devDependencies of the project's package.json, // we will use it as source for engines _e.sent(); ctCnfPath = path_1.default.join(c.paths.project.nodeModulesDir, cnfTemplatesName, core_1.RnvFileName.renativeTemplates); if ((0, core_1.fsExistsSync)(ctCnfPath)) { files.configTemplates.config = (0, core_1.readObjectSync)(ctCnfPath) || undefined; } _e.label = 2; case 2: if (!files.configTemplates.config) { // As fallback we'll use current rnv executor's config-templates files.configTemplates.config = c.files.rnvConfigTemplates.config; } return [2 /*return*/]; } }); }); }; exports.default = Question; //# sourceMappingURL=configTemplates.js.map