fix(paths): treat empty DSH_HOME as unset; isolate telemetry env test

Review fixes for #462:
- resolveDshHome now treats an empty or whitespace-only $DSH_HOME as
  unset, so a blank override never resolves the home to cwd via
  resolve(''). Restores the guard telemetry's old resolver carried.
- The default-env telemetry test asserts only that globalConfigDir()
  returns an absolute path, so a machine DSH_HOME without a .dsh suffix
  cannot break it.
This commit is contained in:
Turtle
2026-07-21 14:43:38 +08:00
parent 92e0d0e04f
commit fac3fc090f
6 changed files with 18 additions and 8 deletions
@@ -1,6 +1,6 @@
import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join, resolve } from 'node:path'
import { isAbsolute, join, resolve } from 'node:path'
import { defaultDshHome } from '@deepseek-ai/dsh-paths'
import { afterEach, describe, expect, it } from 'vitest'
import {
@@ -34,7 +34,9 @@ describe('globalConfigDir', () => {
it('reads process.env by default', () => {
// No override supplied: the call must not throw and must return an absolute path.
expect(globalConfigDir()).toContain('.dsh')
// The ambient DSH_HOME is unknown here, so assert only the invariant the
// resolver guarantees rather than a specific location.
expect(isAbsolute(globalConfigDir())).toBe(true)
})
})