summaryrefslogtreecommitdiff
path: root/src/utils/check-dependencies.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2016-12-29 07:49:51 +0900
committersyuilo <syuilotan@yahoo.co.jp>2016-12-29 07:49:51 +0900
commitb3f42e62af698a67c2250533c437569559f1fdf9 (patch)
treecdf6937576e99cccf85e6fa3aa8860a1173c7cfb /src/utils/check-dependencies.ts
downloadmisskey-b3f42e62af698a67c2250533c437569559f1fdf9.tar.gz
misskey-b3f42e62af698a67c2250533c437569559f1fdf9.tar.bz2
misskey-b3f42e62af698a67c2250533c437569559f1fdf9.zip
Initial commit :four_leaf_clover:
Diffstat (limited to 'src/utils/check-dependencies.ts')
-rw-r--r--src/utils/check-dependencies.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/utils/check-dependencies.ts b/src/utils/check-dependencies.ts
new file mode 100644
index 0000000000..7bcb87a68f
--- /dev/null
+++ b/src/utils/check-dependencies.ts
@@ -0,0 +1,23 @@
+import {logInfo, logDone, logWarn} from 'log-cool';
+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]);
+ logDone('Successfully checked external dependencies');
+}
+
+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) {
+ logInfo(`DEPS: ${serviceName} ${transform(x.stdout)}`);
+ } else if (x.code === code.notFound) {
+ logWarn(`Unable to find ${serviceName}`);
+ }
+}