refactor(config): centralize DSH home paths

This commit is contained in:
Turtle
2026-07-31 16:49:55 +08:00
parent 9e11f438f3
commit 885f1ed1ac
22 changed files with 88 additions and 27 deletions
+12 -1
View File
@@ -1,15 +1,20 @@
import { homedir } from 'node:os'
import { join, resolve } from 'node:path'
import { describe, expect, it } from 'vitest'
import { afterEach, describe, expect, it, vi } from 'vitest'
import {
DEFAULT_DSH_HOME_DISPLAY,
DSH_HOME_DIR_NAME,
defaultDshHome,
dshHomeDisplay,
dshHomePath,
expandHomePath,
resolveDshHome,
} from '@deepseek-ai/dsh-paths'
afterEach(() => {
vi.unstubAllEnvs()
})
describe('dsh path helpers', () => {
it('owns the shared default DSH home directory name', () => {
expect(DSH_HOME_DIR_NAME).toBe('.dsh')
@@ -38,6 +43,12 @@ describe('dsh path helpers', () => {
expect(resolveDshHome(undefined, { DSH_HOME: ' ' })).toBe(defaultDshHome())
})
it('joins child segments onto the resolved DSH_HOME', () => {
vi.stubEnv('DSH_HOME', '~/env-dsh')
expect(dshHomePath()).toBe(join(homedir(), 'env-dsh'))
expect(dshHomePath('storages', 'cache')).toBe(join(homedir(), 'env-dsh', 'storages', 'cache'))
})
it('labels a resolved home by whether it is the default root', () => {
expect(dshHomeDisplay(resolve(defaultDshHome()))).toBe('~/.dsh')
expect(dshHomeDisplay('/some/other/root')).toBe('$DSH_HOME')