dsh-sansheng-liubu/sansheng/src/host/paths.js

15 lines
524 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { homedir } from 'node:os'
import { join } from 'node:path'
/** DSH 主目录,与宿主一致:优先 DSH_HOME,否则 ~/.dsh。 */
export function dshHome(env = process.env) {
const fromEnv = env.DSH_HOME
if (typeof fromEnv === 'string' && fromEnv.trim() !== '') return fromEnv
return join(homedir(), '.dsh')
}
/** 三省六部自己的项目状态文件;与用户其它 DSH 数据分开存放。 */
export function sanshengStatePath(home = dshHome()) {
return join(home, 'sansheng', 'state.json')
}