From ada382f53fabf990aeeff06e6680480acf1aca15 Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Fri, 30 Dec 2016 03:20:25 +0900 Subject: [PATCH] Fix bug --- src/utils/check-dependencies.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/utils/check-dependencies.ts b/src/utils/check-dependencies.ts index 2378041e27..2b19543915 100644 --- a/src/utils/check-dependencies.ts +++ b/src/utils/check-dependencies.ts @@ -2,21 +2,27 @@ import Logger from './logger'; import { exec } from 'shelljs'; export default function(): void { - checkDependency('Node.js', 'node -v', x => x.match(/^v(.*)\r?\n$/)[1]); - checkDependency('npm', 'npm -v', x => x.match(/^(.*)\r?\n$/)[1]); - checkDependency('MongoDB', 'mongo --version', x => x.match(/^MongoDB shell version: (.*)\r?\n$/)[1]); - checkDependency('Redis', 'redis-server --version', x => x.match(/v=([0-9\.]*)/)[1]); + 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(/^MongoDDB shell version: (.*)\r?\n$/)); + checkDependency('Redis', 'redis-server --version', x => x.match(/v=([0-9\.]*)/)); } -function checkDependency(serviceName: string, command: string, transform: (x: string) => string): void { +function checkDependency(serviceName: string, command: string, transform: (x: string) => RegExpMatchArray): void { const code = { success: 0, notFound: 127 }; - const x = exec(command, { silent: true }) as any; let depsLogger = new Logger('Deps'); + const x = exec(command, { silent: true }) as any; if (x.code === code.success) { - depsLogger.info(`${serviceName} ${transform(x.stdout)} found`); + let ver = transform(x.stdout); + if (ver != null) { + depsLogger.info(`${serviceName} ${ver[1]} found`); + } else { + depsLogger.warn(`${serviceName} not found`); + depsLogger.warn(`Regexp used for version check of ${serviceName} is probably messed up`); + } } else if (x.code === code.notFound) { depsLogger.warn(`${serviceName} not found`); }