feat: args as env vars

refactor: use constant for env var prefix
This commit is contained in:
Thomas Dupont 2022-07-06 15:01:23 +02:00 committed by Joachim Van Herwegen
parent df2926a52f
commit a461586921
2 changed files with 8 additions and 2 deletions

View File

@ -65,7 +65,9 @@
}
},
"options": {
"usage": "node ./bin/server.js [args]"
"usage": "node ./bin/server.js [args]",
"envVarPrefix": "CSS",
"loadFromEnv": true
}
}
]

View File

@ -22,6 +22,8 @@ const CORE_CLI_PARAMETERS = {
mainModulePath: { type: 'string', alias: 'm', requiresArg: true },
} as const;
const ENV_VAR_PREFIX = 'CSS';
/**
* A class that can be used to instantiate and start a server based on a Component.js configuration.
*/
@ -112,7 +114,9 @@ export class AppRunner {
.usage('node ./bin/server.js [args]')
.options(CORE_CLI_PARAMETERS)
// We disable help here as it would only show the core parameters
.help(false);
.help(false)
// We also read from environment variables
.env(ENV_VAR_PREFIX);
const params = await yargv.parse();