From 03852c684059271eac015af9fb0dac2b2e878f6e Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Sat, 31 Dec 2016 03:09:31 +0900 Subject: [PATCH] :sparkles: --- src/index.ts | 4 ++-- src/utils/checkDependencies.ts | 29 ----------------------------- 2 files changed, 2 insertions(+), 31 deletions(-) delete mode 100644 src/utils/checkDependencies.ts diff --git a/src/index.ts b/src/index.ts index ff4a01c83..b9c628268 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,7 +18,7 @@ const portUsed = require('tcp-port-used'); const isRoot = require('is-root'); import ProgressBar from './utils/cli/progressbar'; import initdb from './db/mongodb'; -import checkDependencies from './utils/checkDependencies'; +import DependencyChecker from './utils/dependencyChecker'; // Init babel require('babel-core/register'); @@ -175,7 +175,7 @@ async function init(): Promise { configLogger.info('Successfully loaded'); configLogger.info(`maintainer: ${config.maintainer}`); - checkDependencies(); + new DependencyChecker().checkAll(); if (process.platform === 'linux' && !isRoot() && config.port < 1024) { Logger.error('You need root privileges to listen on port below 1024 on Linux'); diff --git a/src/utils/checkDependencies.ts b/src/utils/checkDependencies.ts deleted file mode 100644 index 01c0b5053..000000000 --- a/src/utils/checkDependencies.ts +++ /dev/null @@ -1,29 +0,0 @@ -import Logger from './logger'; -import { exec } from 'shelljs'; - -export default function(): void { - checkDependency('Node.js', 'node -v', x => x.match(/^v(.*)\r?\n$/)); - checkDependency('npm', 'npm -v', x => x.match(/^(.*)\r?\n$/)); - checkDependency('MongoDB', 'mongo --version', x => x.match(/^MongoDB shell version: (.*)\r?\n$/)); - checkDependency('Redis', 'redis-server --version', x => x.match(/v=([0-9\.]*)/)); -} - -function checkDependency(serviceName: string, command: string, transform: (x: string) => RegExpMatchArray): void { - const code = { - success: 0, - notFound: 127 - }; - let logger = new Logger('Deps'); - const x = exec(command, { silent: true }) as any; - if (x.code === code.success) { - let ver = transform(x.stdout); - if (ver != null) { - logger.info(`${serviceName} ${ver[1]} found`); - } else { - logger.warn(`${serviceName} not found`); - logger.warn(`Regexp used for version check of ${serviceName} is probably messed up`); - } - } else if (x.code === code.notFound) { - logger.warn(`${serviceName} not found`); - } -}