UNPKG

@ably/cli

Version:

Ably CLI for Pub/Sub, Chat and Spaces

29 lines (28 loc) 961 B
import * as fs from "node:fs"; import { AblyBaseCommand } from "../../base-command.js"; export default class ConfigPath extends AblyBaseCommand { static description = "Print the path to the Ably CLI config file"; static examples = [ "<%= config.bin %> <%= command.id %>", "# Open in your preferred editor:", "code $(ably config path)", "vim $(ably config path)", ]; static flags = { ...AblyBaseCommand.globalFlags, }; async run() { const { flags } = await this.parse(ConfigPath); const configPath = this.configManager.getConfigPath(); // Create the config file if it doesn't exist if (!fs.existsSync(configPath)) { this.configManager.saveConfig(); } if (this.shouldOutputJson(flags)) { this.log(this.formatJsonOutput({ path: configPath }, flags)); } else { this.log(configPath); } } }