移除用户判断

This commit is contained in:
whyour 2025-11-15 17:02:00 +08:00
parent 72d4c8bfd4
commit 45fac29804
2 changed files with 0 additions and 19 deletions

View File

@ -3,8 +3,6 @@ import fs from 'fs/promises';
import os from 'os'; import os from 'os';
import chokidar from 'chokidar'; import chokidar from 'chokidar';
import config from '../config/index'; import config from '../config/index';
import { promiseExec } from '../config/util';
import { W_OK } from 'constants';
import Logger from './logger'; import Logger from './logger';
async function linkToNodeModule(src: string, dst?: string) { async function linkToNodeModule(src: string, dst?: string) {
@ -19,24 +17,11 @@ async function linkToNodeModule(src: string, dst?: string) {
} catch (error) { } } catch (error) { }
} }
async function ensureDirWritable(dir: string) {
try {
await fs.access(dir, W_OK);
return true;
} catch {
return false;
}
}
async function linkCommand() { async function linkCommand() {
const homeDir = os.homedir(); const homeDir = os.homedir();
let userBinDir = path.join(homeDir, 'bin'); let userBinDir = path.join(homeDir, 'bin');
try { try {
if (!(await ensureDirWritable(homeDir))) {
const commandPath = await promiseExec('which node');
userBinDir = path.dirname(commandPath);
}
await fs.mkdir(userBinDir, { recursive: true }); await fs.mkdir(userBinDir, { recursive: true });
await linkCommandToDir(userBinDir); await linkCommandToDir(userBinDir);
} catch (error) { } catch (error) {

View File

@ -1,15 +1,12 @@
#!/bin/bash #!/bin/bash
# Add ~/bin to PATH for non-root users
export PATH="$HOME/bin:$PATH" export PATH="$HOME/bin:$PATH"
dir_shell=/ql/shell dir_shell=/ql/shell
. $dir_shell/share.sh . $dir_shell/share.sh
export_ql_envs() { export_ql_envs() {
# Export BACK_PORT from QlPort for backend server to use
export BACK_PORT="${ql_port}" export BACK_PORT="${ql_port}"
# Export GRPC_PORT from QlGrpcPort for gRPC server to use
export GRPC_PORT="${ql_grpc_port}" export GRPC_PORT="${ql_grpc_port}"
} }
@ -17,7 +14,6 @@ log_with_style() {
local level="$1" local level="$1"
local message="$2" local message="$2"
local timestamp=$(date '+%Y-%m-%d %H:%M:%S') local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
printf "\n[%s] [%7s] %s\n" "${timestamp}" "${level}" "${message}" printf "\n[%s] [%7s] %s\n" "${timestamp}" "${level}" "${message}"
} }