mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-22 09:57:29 -07:00
Fix bug
This commit is contained in:
parent
5d9fb1b513
commit
b05f2ce71c
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