PostHog / PostHog/wizard

yargs.terminalWidth() does not work: TypeError: import_yargs.default.terminalWidth is not a function

Open
#228 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
197
Forks
51
Avg merge
1d 23h
Merged PRs (30d)
94

Description

Current code in bin.ts that throws an error:

yargs(hideBin(process.argv))
  .env('POSTHOG_WIZARD')
   // more chained methods
   .help()
  .alias('help', 'h')
  .version()
  .alias('version', 'v')
  .wrap(process.stdout.isTTY ? yargs.terminalWidth() : 80).argv;

Expected something like:

import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';

// Create a yargs instance
const yargInstance = yargs(hideBin(process.argv));

// Use terminalWidth() on the instance
const terminalWidth = yargInstance.terminalWidth();

// Example of using the width with .wrap()
yargInstance.wrap(terminalWidth)
    .argv

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in bin.ts, where the CLI chain calls yargs.terminalWidth() while configuring .wrap(). Compare that call with the instance-based usage shown in the issue, then run the wizard command and confirm terminal-width handling no longer throws the reported TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.