File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -163,14 +163,17 @@ export function usage(yargs: YargsInstance, shim: PlatformShim) {
163
163
wrap = cols ;
164
164
} ;
165
165
166
- function getWrap ( ) {
166
+ self . getWrap = ( ) => {
167
+ if ( shim . getEnv ( 'YARGS_DISABLE_WRAP' ) ) {
168
+ return null ;
169
+ }
167
170
if ( ! wrapSet ) {
168
171
wrap = windowWidth ( ) ;
169
172
wrapSet = true ;
170
173
}
171
174
172
175
return wrap ;
173
- }
176
+ } ;
174
177
175
178
const deferY18nLookupPrefix = '__yargsString__:' ;
176
179
self . deferY18nLookup = str => deferY18nLookupPrefix + str ;
@@ -202,7 +205,7 @@ export function usage(yargs: YargsInstance, shim: PlatformShim) {
202
205
} , { } as Dictionary < boolean > )
203
206
) ;
204
207
205
- const theWrap = getWrap ( ) ;
208
+ const theWrap = self . getWrap ( ) ;
206
209
const ui = shim . cliui ( {
207
210
width : theWrap ,
208
211
wrap : ! ! theWrap ,
@@ -769,6 +772,7 @@ export interface UsageInstance {
769
772
getPositionalGroupName ( ) : string ;
770
773
getUsage ( ) : [ string , string ] [ ] ;
771
774
getUsageDisabled ( ) : boolean ;
775
+ getWrap ( ) : number | nil ;
772
776
help ( ) : string ;
773
777
reset ( localLookup : Dictionary < boolean > ) : UsageInstance ;
774
778
showHelp ( level ?: 'error' | 'log' | ( ( message : string ) => void ) ) : void ;
Original file line number Diff line number Diff line change @@ -1912,7 +1912,16 @@ describe('usage tests', () => {
1912
1912
1913
1913
// the long description should cause several line
1914
1914
// breaks when wrapped.
1915
- r . errors [ 0 ] . split ( '\n' ) . length . should . gte ( 4 ) ;
1915
+ r . errors [ 0 ] . split ( '\n' ) . length . should . gte ( 5 ) ;
1916
+ } ) ;
1917
+
1918
+ it ( 'should not wrap when YARGS_DISABLED_WRAP is provided' , ( ) => {
1919
+ const yargsInstance = yargs ( ) . wrap ( 99 ) ;
1920
+ process . env . YARGS_DISABLE_WRAP = 'true' ;
1921
+ expect (
1922
+ yargsInstance . getInternalMethods ( ) . getUsageInstance ( ) . getWrap ( )
1923
+ ) . to . equal ( null ) ;
1924
+ delete process . env . YARGS_DISABLE_WRAP ;
1916
1925
} ) ;
1917
1926
1918
1927
it ( 'should not raise an exception when long default and description are provided' , ( ) =>
You can’t perform that action at this time.
0 commit comments