Fix bug
This commit is contained in:
parent
a81d908a4d
commit
ada382f53f
1 changed files with 13 additions and 7 deletions
|
@ -2,21 +2,27 @@ import Logger from './logger';
|
||||||
import { exec } from 'shelljs';
|
import { exec } from 'shelljs';
|
||||||
|
|
||||||
export default function(): void {
|
export default function(): void {
|
||||||
checkDependency('Node.js', 'node -v', x => x.match(/^v(.*)\r?\n$/)[1]);
|
checkDependency('Node.js', 'node -v', x => x.match(/^v(.*)\r?\n$/));
|
||||||
checkDependency('npm', 'npm -v', x => x.match(/^(.*)\r?\n$/)[1]);
|
checkDependency('npm', 'npm -v', x => x.match(/^(.*)\r?\n$/));
|
||||||
checkDependency('MongoDB', 'mongo --version', x => x.match(/^MongoDB shell version: (.*)\r?\n$/)[1]);
|
checkDependency('MongoDB', 'mongo --version', x => x.match(/^MongoDDB shell version: (.*)\r?\n$/));
|
||||||
checkDependency('Redis', 'redis-server --version', x => x.match(/v=([0-9\.]*)/)[1]);
|
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 = {
|
const code = {
|
||||||
success: 0,
|
success: 0,
|
||||||
notFound: 127
|
notFound: 127
|
||||||
};
|
};
|
||||||
const x = exec(command, { silent: true }) as any;
|
|
||||||
let depsLogger = new Logger('Deps');
|
let depsLogger = new Logger('Deps');
|
||||||
|
const x = exec(command, { silent: true }) as any;
|
||||||
if (x.code === code.success) {
|
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) {
|
} else if (x.code === code.notFound) {
|
||||||
depsLogger.warn(`${serviceName} not found`);
|
depsLogger.warn(`${serviceName} not found`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue