File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -104,4 +104,18 @@ export default class Config {
104104 #writeConfig( ) {
105105 fs . writeFileSync ( this . configPath , yaml . dump ( this . #config) ) ;
106106 }
107+
108+ /* -------------------------------------------- */
109+
110+ /**
111+ * Load a local configuration file
112+ * @param {string } configFile The path to the config file
113+ */
114+ loadLocalConf ( configFile ) {
115+ if ( ! fs . existsSync ( configFile ) ) return ;
116+ /** @type {Record<string, any> } */
117+ const conf = yaml . load ( fs . readFileSync ( configFile , "utf8" ) ) ;
118+ this . configPath = configFile ;
119+ for ( const key of Object . keys ( conf ) ) this . #config[ key ] = conf [ key ] ;
120+ }
107121}
Original file line number Diff line number Diff line change @@ -5,9 +5,14 @@ import { hideBin } from "yargs/helpers";
55import { getCommand as configureCommand } from "./commands/configuration.mjs" ;
66import { getCommand as packageCommand } from "./commands/package.mjs" ;
77import { getCommand as launchCommand } from "./commands/launch.mjs" ;
8+ import Config from "./config.mjs" ;
89
910const argv = yargs ( hideBin ( process . argv ) )
1011 . usage ( "Usage: $0 <command> [options]" )
12+ . config ( "config" , "Path to YAML config file" , function ( configFile ) {
13+ Config . instance . loadLocalConf ( configFile ) ;
14+ return Config . instance . getAll ( ) ;
15+ } )
1116 . command ( configureCommand ( ) )
1217 . command ( packageCommand ( ) )
1318 . command ( launchCommand ( ) )
You can’t perform that action at this time.
0 commit comments