UNPKG

@nickmaina/mongors

Version:

A very opinionated cli to run a MongoDB replica set locally for development

33 lines (32 loc) 1.31 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const find_cache_dir_1 = __importDefault(require("find-cache-dir")); const os_1 = __importDefault(require("os")); const child_process_1 = __importDefault(require("child_process")); exports.isWindows = process.platform === "win32"; exports.where = exports.isWindows ? "where" : "command -v"; exports.thunk = find_cache_dir_1.default({ name: "mongors", create: true, thunk: true }); exports.thunkDataPath = (f) => exports.thunk("data", f); exports.LOG_PATH = exports.thunk("log", "mongod.log"); exports.DEFAULT_DBPATH = exports.thunk("data"); exports.CACHE_PATH = exports.thunk(); exports.DEFAULT_PORT = 27017; exports.DEFAULT_KEEP = true; exports.DEFAULT_FORK = false; exports.DEFAULT_HOSTNAME = process.platform === "win32" ? os_1.default.hostname() : "localhost"; exports.DEFAULT_OPTIONS = { port: exports.DEFAULT_PORT }; function _isMongoInstalled() { try { child_process_1.default.execSync(`${exports.where} mongod`); return true; } catch (_a) { return false; } } exports.isMongoInstalled = _isMongoInstalled();