(args)
| 548 | } |
| 549 | |
| 550 | function handleConfig(args) { |
| 551 | ensureEnvFile(); |
| 552 | |
| 553 | if (args.includes('--path')) { |
| 554 | console.log(ENV_FILE); |
| 555 | return; |
| 556 | } |
| 557 | |
| 558 | if (args.includes('--show')) { |
| 559 | if (!existsSync(ENV_FILE)) { |
| 560 | log('No configuration file found.'); |
| 561 | return; |
| 562 | } |
| 563 | const lines = readFileSync(ENV_FILE, 'utf8').split('\n'); |
| 564 | const active = lines.filter(l => { |
| 565 | const t = l.trim(); |
| 566 | return t && !t.startsWith('#'); |
| 567 | }); |
| 568 | if (active.length === 0) { |
| 569 | log('No active configuration. All lines are commented out.'); |
| 570 | log(`Edit: ${ENV_FILE}`); |
| 571 | } else { |
| 572 | for (const line of active) { |
| 573 | console.log(line); |
| 574 | } |
| 575 | } |
| 576 | return; |
| 577 | } |
| 578 | |
| 579 | // Open in editor |
| 580 | const editor = process.env.EDITOR || process.env.VISUAL || (IS_WIN ? 'notepad' : 'vi'); |
| 581 | try { |
| 582 | execFileSync(editor, [ENV_FILE], { stdio: 'inherit' }); |
| 583 | } catch { |
| 584 | log(`Could not open editor "${editor}".`); |
| 585 | log(`Edit the file manually: ${ENV_FILE}`); |
| 586 | } |
| 587 | } |
| 588 | |
| 589 | // --------------------------------------------------------------------------- |
| 590 | // Main server start |
no test coverage detected