mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
fix: set default TUNWG_PATH and support ~ in HAPI_HOME
Extract getHapiHome() helper to properly expand ~ prefix in HAPI_HOME env var. Set TUNWG_PATH default to $HAPI_HOME/tunwg when not specified.
This commit is contained in:
@@ -17,6 +17,12 @@ function isBunCompiled(): boolean {
|
||||
return typeof process.execPath === 'string' && !process.execPath.includes('bun')
|
||||
}
|
||||
|
||||
function getHapiHome(): string {
|
||||
return process.env.HAPI_HOME
|
||||
? process.env.HAPI_HOME.replace(/^~/, homedir())
|
||||
: join(homedir(), '.hapi')
|
||||
}
|
||||
|
||||
function getPlatformDir(): string {
|
||||
const platformName = platform()
|
||||
const archName = arch()
|
||||
@@ -39,7 +45,7 @@ function getTunwgPath(): string {
|
||||
const tunwgBinary = isWin ? 'tunwg.exe' : 'tunwg'
|
||||
|
||||
if (isBunCompiled()) {
|
||||
const hapiHome = process.env.HAPI_HOME || join(homedir(), '.hapi')
|
||||
const hapiHome = getHapiHome()
|
||||
const packageJson = require('../../../cli/package.json')
|
||||
const runtimePath = join(hapiHome, 'runtime', packageJson.version)
|
||||
return join(runtimePath, 'tools', 'tunwg', tunwgBinary)
|
||||
@@ -106,6 +112,10 @@ export class TunnelManager {
|
||||
|
||||
const env: Record<string, string> = { ...process.env as Record<string, string> }
|
||||
|
||||
if (!env.TUNWG_PATH) {
|
||||
env.TUNWG_PATH = join(getHapiHome(), 'tunwg')
|
||||
}
|
||||
|
||||
if (this.config.apiDomain) {
|
||||
env.TUNWG_API = this.config.apiDomain
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user