UNPKG

inversitron

Version:
37 lines (36 loc) 2.38 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.runInversitronApp = void 0; var colors_1 = require("colors"); var fs_1 = require("fs"); var nodemon_1 = __importDefault(require("nodemon")); var path_1 = require("path"); var process_1 = require("process"); var readConfigFile_1 = __importDefault(require("../../utils/readConfigFile")); function runInversitronApp(configPath) { var _a, _b, _c, _d, _e; var configFilePath = configPath !== null && configPath !== void 0 ? configPath : process_1.cwd(); var configs = readConfigFile_1.default(configPath); var rootDir = JSON.parse(fs_1.readFileSync(path_1.join(configFilePath, 'tsconfig.json')).toString('utf-8')).compilerOptions.rootDir; nodemon_1.default(__assign(__assign({}, configs.nodemon), { spawn: true, env: __assign(__assign({}, configs.nodemon.env), { NODE_ENV: 'DEV', H: 'http://localhost', PORT: (_a = configs.dev.port) !== null && _a !== void 0 ? _a : 5000, RP: (_b = configs.dev.rootPath) !== null && _b !== void 0 ? _b : '/', CO: configs.dev.corsOrigin, CFP: configFilePath, REPOS_P: (_c = configs.repositoriesPath) !== null && _c !== void 0 ? _c : path_1.join(rootDir, 'repositories'), CTRLS_P: (_d = configs.controllersPath) !== null && _d !== void 0 ? _d : path_1.join(rootDir, 'controllers'), SERVS_P: (_e = configs.servicesPath) !== null && _e !== void 0 ? _e : path_1.join(rootDir, 'services') }) })) .on('start', function () { return console.log(colors_1.cyan('\nServer started\n')); }) .on('restart', function () { return console.log(colors_1.cyan('\nServer restarted\n')); }) .on('exit', function () { return console.log(colors_1.cyan('\nServer shut down\n')); }); } exports.runInversitronApp = runInversitronApp; var dev = function (cmd) { return runInversitronApp(cmd.config); }; exports.default = dev;