2016-12-29 08:36:03 +00:00
|
|
|
import { log } from './logger';
|
2016-12-29 08:41:19 +00:00
|
|
|
import { exec } from 'shelljs';
|
2016-12-28 22:49:51 +00:00
|
|
|
|
|
|
|
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]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkDependency(serviceName: string, command: string, transform: (x: string) => string): void {
|
|
|
|
const code = {
|
|
|
|
success: 0,
|
|
|
|
notFound: 127
|
|
|
|
};
|
|
|
|
const x = exec(command, { silent: true }) as any;
|
|
|
|
if (x.code === code.success) {
|
2016-12-29 11:16:06 +00:00
|
|
|
log('Info', `${serviceName} ${transform(x.stdout)} found`, 'Deps');
|
2016-12-28 22:49:51 +00:00
|
|
|
} else if (x.code === code.notFound) {
|
2016-12-29 11:16:06 +00:00
|
|
|
log('Warn', `${serviceName} not found`, 'Deps');
|
2016-12-28 22:49:51 +00:00
|
|
|
}
|
|
|
|
}
|