fix: command line arguments didn't handle some value types, like boolean
Massimo Melina committed
Sep 25, 2025 at 19:50 UTC
bc4b02519b743ee1f44829809e7a1aa8b3c19e58
2 files changed
+11
-9
config.md
+6
-5
@@ -30,11 +30,12 @@ Configuration can be done in several ways
30
- accessing the Admin-panel with your browser
31
- it will automatically open when you start HFS. Bookmark it.
32
If your port is 8000 the address will be http://localhost:8000/~/admin
33
-- passing via command line at start in the form `--NAME VALUE`
34
-- using envs in the form `HFS_<uppercase property name>`, like `HFS_PORT=80` if you want to change the config `port`, but same applies to any other config available,
35
-- directly editing the `config.yaml` file. As soon as you save it is reloaded and changes are applied
36
- - if you don't want to use an editor, consider typing this (example) command inside the folder where the config file is:
37
- `echo "port: 1080" >> config.yaml`
33
+- directly editing the `config.yaml` file. As soon as you save, it is reloaded and changes are applied
34
+ - if you don't want to use an editor, consider typing this (example) command inside the folder where the config file is:
35
+ `echo "port: 1080" >> config.yaml`
36
+- passing via command line at start in the form `--NAME VALUE`. Values can use JSON syntax.
37
+- using envs in the form `HFS_<uppercase property name>`, like `HFS_PORT=80` if you want to change the config `port`,
38
+ but the same applies to any other config available. Values can use JSON syntax.
39
- after HFS has started you can enter console command in the form `config NAME VALUE`
40
- setting special env `HFS_ENV_BOOTSTRAP=true` will disable other envs when file config.yaml already exists.
41
- env `DISABLE_UPDATE` (designed for containers) will disable updating, but check-for-update will still be possible.
src/config.ts
+5
-4
@@ -125,11 +125,12 @@ export async function setConfig(newCfg: Record<string,unknown>, save?: boolean)
125
const version = _.isString(newCfg.version) ? new Version(newCfg.version) : undefined
126
const considerEnvs = !process.env['HFS_ENV_BOOTSTRAP'] || !started && _.isEmpty(newCfg)
127
// first time we consider also CLI args
128
- const argCfg = !started && _.pickBy(newObj(configProps,
129
- (x, k) => argv[k] ?? tryJson(considerEnvs ? process.env['HFS_' + k.toUpperCase().replaceAll('-','_')] : '', _.identity)),
130
- x => x !== undefined)
128
+ const argCfg = !started && _.pickBy(
129
+ newObj(configProps, (_x, k) =>
130
+ tryJson(k in argv ? argv[k] : considerEnvs ? process.env['HFS_' + k.toUpperCase().replaceAll('-','_')] : '', _.identity) ),
131
+ x => x !== undefined )
132
if (!_.isEmpty(argCfg)) {
132
- saveConfigAsap() // don't set `save` argument, as it would interfere below at check `save===false`
133
+ saveConfigAsap() // don't set `save` argument, as it would interfere below, at check `save===false`
134
Object.assign(newCfg, argCfg)
135
}
136
await Promise.allSettled(Object.keys(newCfg).map(k =>