Skip to content

Commit 52d788a

Browse files
committed
fix(install proxy): 检测权限
1 parent 877896c commit 52d788a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/commands/server.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,13 @@ exports.run = function (options) {
4040

4141
var isGoingToStartServer = true;
4242

43-
// 检测预装插件
43+
// 检测前置条件
4444
if (proxy) {
45+
if (!(process.getuid && process.getuid() === 0)) {
46+
warn('权限不足, 请使用sudo执行');
47+
process.exit(1);
48+
}
49+
4550
try {
4651
require.resolve("@qnpm/jerryproxy-ykit");
4752
} catch (e) {

src/commands/server.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,13 @@ exports.run = (options) => {
4040

4141
let isGoingToStartServer = true
4242

43-
// 检测预装插件
43+
// 检测前置条件
4444
if(proxy){
45+
if(!(process.getuid && process.getuid() === 0)){
46+
warn('权限不足, 请使用sudo执行')
47+
process.exit(1)
48+
}
49+
4550
try {
4651
require.resolve("@qnpm/jerryproxy-ykit")
4752
} catch(e) {

0 commit comments

Comments
 (0)