refactor(cli): drop the redundant existence pre-check in resolveWindowsShellLayer
loadOverlayPatches already throws on a missing file (the caller named it, so absence is a misconfiguration) — the existsSync guard was a second fail-loud mechanism for the same miss with a prettier message. The loader's throw keeps the fail-loud contract the Windows-default note records.
This commit is contained in:
@@ -10,7 +10,6 @@
|
|||||||
* @module @deepseek-ai/dsh/windows-shell
|
* @module @deepseek-ai/dsh/windows-shell
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { existsSync } from 'node:fs'
|
|
||||||
import { join } from 'node:path'
|
import { join } from 'node:path'
|
||||||
import type { PatchOptions } from '@cordisjs/plugin-include'
|
import type { PatchOptions } from '@cordisjs/plugin-include'
|
||||||
import { loadOverlayPatches, type ProfileLayer } from '@deepseek-ai/dsh-app-boot'
|
import { loadOverlayPatches, type ProfileLayer } from '@deepseek-ai/dsh-app-boot'
|
||||||
@@ -36,8 +35,9 @@ export interface WindowsShellLayer {
|
|||||||
* @param binName - the diagnostic prefix on thrown errors (`dsh`).
|
* @param binName - the diagnostic prefix on thrown errors (`dsh`).
|
||||||
* @returns the pwsh layer on win32, else `undefined`. A custom profile that
|
* @returns the pwsh layer on win32, else `undefined`. A custom profile that
|
||||||
* mounts no base bundle is skipped (it owns its shell stack); a base
|
* mounts no base bundle is skipped (it owns its shell stack); a base
|
||||||
* bundle that ships no Windows shell patch fails loud — the shipped
|
* bundle whose Windows shell patch is missing fails loud in
|
||||||
* package always carries it, so a miss is a broken installation.
|
* {@link loadOverlayPatches} — the shipped package always carries it, so
|
||||||
|
* a miss is a broken installation.
|
||||||
*/
|
*/
|
||||||
export function resolveWindowsShellLayer(
|
export function resolveWindowsShellLayer(
|
||||||
platform: NodeJS.Platform,
|
platform: NodeJS.Platform,
|
||||||
@@ -48,8 +48,5 @@ export function resolveWindowsShellLayer(
|
|||||||
const base = layers.find(layer => layer.packageName === BASE_BUNDLE)
|
const base = layers.find(layer => layer.packageName === BASE_BUNDLE)
|
||||||
if (base === undefined) return undefined
|
if (base === undefined) return undefined
|
||||||
const label = join(base.packageDir, WINDOWS_SHELL_PATCH_FILENAME)
|
const label = join(base.packageDir, WINDOWS_SHELL_PATCH_FILENAME)
|
||||||
if (!existsSync(label)) {
|
|
||||||
throw new Error(`${binName}: ${BASE_BUNDLE} ships no ${WINDOWS_SHELL_PATCH_FILENAME}`)
|
|
||||||
}
|
|
||||||
return { label, patches: loadOverlayPatches(binName, label) }
|
return { label, patches: loadOverlayPatches(binName, label) }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,8 +60,10 @@ describe('resolveWindowsShellLayer', () => {
|
|||||||
it('fails loud when the base bundle ships no Windows shell patch', () => {
|
it('fails loud when the base bundle ships no Windows shell patch', () => {
|
||||||
const base = tempBase()
|
const base = tempBase()
|
||||||
mkdirSync(base, { recursive: true })
|
mkdirSync(base, { recursive: true })
|
||||||
|
// The overlay loader owns the fail-loud contract: the caller named this
|
||||||
|
// file, so its absence is a misconfiguration, not "no overlay".
|
||||||
expect(() => resolveWindowsShellLayer('win32', [fakeLayer(BASE_BUNDLE, base)], 'dsh'))
|
expect(() => resolveWindowsShellLayer('win32', [fakeLayer(BASE_BUNDLE, base)], 'dsh'))
|
||||||
.toThrow(/@deepseek-ai\/dsh-base ships no windows\.cordis\.patch\.yml/)
|
.toThrow(/dsh: failed to read overlay .*windows\.cordis\.patch\.yml/)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user