Skip to content

Commit 0b0e647

Browse files
committed
Update useConfig to pkgx^2 rules
1 parent e44ce79 commit 0b0e647

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/hooks/useConfig.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,18 @@ const SEP = Deno.build.os == 'windows' ? ';' : ':'
5151

5252
export function ConfigDefault(env = Deno.env.toObject()): Config {
5353
const home = flatmap(env['PKGX_HOME'], x => new Path(x)) ?? Path.home()
54-
const prefix = flatmap(env['PKGX_DIR']?.trim(), x => new Path(x)) ?? home.join('.pkgx')
54+
const prefix = flatmap(env['PKGX_DIR']?.trim(), x => new Path(x)) ??
55+
flatmap(env['XDG_DATA_HOME'], x => new Path(x).join("pkgx")) ??
56+
home.join('.pkgx')
5557
const pantries = env['PKGX_PANTRY_PATH']?.split(SEP).compact(x => flatmap(x.trim(), x => Path.abs(x) ?? Path.cwd().join(x))) ?? []
56-
const cache = (flatmap(env["XDG_CACHE_HOME"], Path.abs) ?? platform_cache_default(home, env)).join("pkgx")
57-
const data = (flatmap(env["XDG_DATA_HOME"], Path.abs) ?? platform_data_home_default(home, env)).join("pkgx")
58+
const cache = (
59+
(Deno.build.os == 'linux' ? flatmap(env["XDG_CACHE_HOME"], Path.abs) : undefined)
60+
?? platform_cache_default(home, env)
61+
).join("pkgx")
62+
const data = (
63+
(Deno.build.os == 'linux' ? flatmap(env["XDG_DATA_HOME"], Path.abs) : undefined)
64+
?? platform_data_home_default(home, env)
65+
).join("pkgx")
5866
const dist = env['PKGX_DIST_URL']?.trim() ?? 'https://dist.pkgx.dev'
5967
const isCI = boolize(env['CI']) ?? false
6068
const UserAgent = flatmap(getv(), v => `libpkgx/${v}`) ?? 'libpkgx'

0 commit comments

Comments
 (0)