Skip to content

feat(usage): add YARGS_DISABLE_WRAP env variable to disable wrap#2210

Merged
bcoe merged 5 commits intoyargs:mainfrom
jgoux:main
Jul 18, 2022
Merged

feat(usage): add YARGS_DISABLE_WRAP env variable to disable wrap#2210
bcoe merged 5 commits intoyargs:mainfrom
jgoux:main

Conversation

@jgoux
Copy link
Contributor

@jgoux jgoux commented Jul 10, 2022

Resolves #2200

I had to modify the test should wrap based on window-size if no wrap is provided because the actual length of the non-wrapped output is 5 and not 4. 👍

@jgoux
Copy link
Contributor Author

jgoux commented Jul 13, 2022

@bcoe Seems like I needed to use the shim to be compatible with deno. It should be good now. 👍

Copy link
Member

@bcoe bcoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this contribution, left a suggestion as to how we could potentially keep 100% coverage, and avoid skipping your test.

lib/usage.ts Outdated
@@ -164,6 +164,9 @@ export function usage(yargs: YargsInstance, shim: PlatformShim) {
};

function getWrap() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that we can maintain our coverage #s, I would do this:

this.getWrap = () => {
  ...
}

And then your test can simply be:

const yargs = yargs().wrap(99);
process.env.YARGS_DISABLE_WRAP = 'true';
expect(yargs.getInternalMethods().getUsageInstance().getWrap()).to.equal(null);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the changes 👍

@bcoe bcoe merged commit b680ace into yargs:main Jul 18, 2022
@bcoe
Copy link
Member

bcoe commented Jul 18, 2022

@jgoux thank you for the contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide an environment variable to disable columns wrapping

2 participants