From 4183680082b3fef4f28cfdaad9d8891653d177bd Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 30 Dec 2016 01:35:25 +0900 Subject: [PATCH] :yen: Implement #2 :yen: --- package.json | 1 + src/index.ts | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/package.json b/package.json index 0ca2141f6..1aded0307 100644 --- a/package.json +++ b/package.json @@ -92,6 +92,7 @@ "gulp-uglify": "2.0.0", "gulp-util": "3.0.8", "inquirer": "2.0.0", + "is-root": "1.0.0", "js-yaml": "3.7.0", "livescript": "1.5.0", "mime-types": "2.1.13", diff --git a/src/index.ts b/src/index.ts index 85833baef..d6de290df 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,6 +15,7 @@ import Logger from './utils/logger'; import * as chalk from 'chalk'; const git = require('git-last-commit'); const portUsed = require('tcp-port-used'); +const isRoot = require('is-root'); import ProgressBar from './utils/cli/progressbar'; import initdb from './db/mongodb'; import checkDependencies from './utils/check-dependencies'; @@ -176,6 +177,11 @@ async function init(): Promise { checkDependencies(); + if (process.platform === 'linux' && !isRoot() && config.port < 1024) { + Logger.error('You need root privilages to listen on port below 1024 on Linux'); + return State.failed; + } + // Check if a port is being used if (await portUsed.check(config.port)) { Logger.error(`Port: ${config.port} is already used!`);