From ab54e147f2a170f2a4ee841ace8537e0ab6a1dab Mon Sep 17 00:00:00 2001 From: rinsuki <428rinsuki+git@gmail.com> Date: Thu, 19 Aug 2021 16:27:12 +0900 Subject: [PATCH] Remove is-root dependencies (#7660) --- package.json | 1 - src/@types/is-root.d.ts | 7 ------- src/boot/master.ts | 6 +++++- yarn.lock | 5 ----- 4 files changed, 5 insertions(+), 14 deletions(-) delete mode 100644 src/@types/is-root.d.ts diff --git a/package.json b/package.json index 1f7d570f5..093f0d99c 100644 --- a/package.json +++ b/package.json @@ -153,7 +153,6 @@ "http-signature": "1.3.5", "idb-keyval": "5.1.3", "insert-text-at-cursor": "0.3.0", - "is-root": "2.1.0", "is-svg": "4.3.1", "js-yaml": "4.1.0", "jsdom": "16.7.0", diff --git a/src/@types/is-root.d.ts b/src/@types/is-root.d.ts deleted file mode 100644 index 3905a16c8..000000000 --- a/src/@types/is-root.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare module 'is-root' { - function isRoot(): boolean; - - namespace isRoot {} // Hack - - export = isRoot; -} diff --git a/src/boot/master.ts b/src/boot/master.ts index 473e215ba..3d86a5dab 100644 --- a/src/boot/master.ts +++ b/src/boot/master.ts @@ -2,7 +2,6 @@ import * as os from 'os'; import * as cluster from 'cluster'; import * as chalk from 'chalk'; import * as portscanner from 'portscanner'; -import * as isRoot from 'is-root'; import { getConnection } from 'typeorm'; import Logger from '../services/logger'; @@ -39,6 +38,11 @@ function greet() { bootLogger.info(`Misskey v${meta.version}`, null, true); } +function isRoot() { + // maybe process.getuid will be undefined under not POSIX environment (e.g. Windows) + return process.getuid != null && process.getuid() === 0; +} + /** * Init master process */ diff --git a/yarn.lock b/yarn.lock index ecb0ff973..13e906a26 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6383,11 +6383,6 @@ is-resolvable@^1.1.0: resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.1.0.tgz#fb18f87ce1feb925169c9a407c19318a3206ed88" integrity sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg== -is-root@2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-root/-/is-root-2.1.0.tgz#809e18129cf1129644302a4f8544035d51984a9c" - integrity sha512-AGOriNp96vNBd3HtU+RzFEc75FfR5ymiYv8E553I71SCeXBiMsVDUtdio1OEFvrPyLIQ9tVR5RxXIFe5PUFjMg== - is-stream@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.0.tgz#bde9c32680d6fae04129d6ac9d921ce7815f78e3"