mirror of
https://github.com/iflytek/skillhub.git
synced 2026-10-05 02:41:49 +00:00
feat(cli): support SKILLHUB_REGISTRY env var for registry URL
Priority: SKILLHUB_REGISTRY env var > ~/.skillhub/config.json > default
This commit is contained in:
parent
c9644e8032
commit
626490e554
1 changed files with 10 additions and 0 deletions
|
|
@ -15,6 +15,16 @@ const DEFAULT_CONFIG: CliConfig = {
|
|||
};
|
||||
|
||||
export function loadConfig(): CliConfig {
|
||||
const envRegistry = process.env.SKILLHUB_REGISTRY;
|
||||
if (envRegistry) {
|
||||
if (!existsSync(CONFIG_FILE)) return { registry: envRegistry };
|
||||
try {
|
||||
const raw = readFileSync(CONFIG_FILE, "utf-8");
|
||||
return { registry: envRegistry, ...JSON.parse(raw) };
|
||||
} catch {
|
||||
return { registry: envRegistry };
|
||||
}
|
||||
}
|
||||
if (!existsSync(CONFIG_FILE)) return { ...DEFAULT_CONFIG };
|
||||
try {
|
||||
const raw = readFileSync(CONFIG_FILE, "utf-8");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue