1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-15 15:05:47 +02:00
Files
misskey/src/utils/check-dependencies.ts
2016-12-29 20:12:26 +09:00

23 lines
821 B
TypeScript

import { log } 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]);
}
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) {
log('Info', `${serviceName} ${transform(x.stdout)}`, 'Deps');
} else if (x.code === code.notFound) {
log('Warn', `${serviceName} not found`);
}
}