@@ -270,8 +270,9 @@ export async function main({
270
270
delete parsedArgs . _ ;
271
271
272
272
// Add prompts.
273
- workflow . registry . usePromptProvider ( _createPromptProvider ( ) ) ;
274
-
273
+ if ( argv [ 'interactive' ] && isTTY ( ) ) {
274
+ workflow . registry . usePromptProvider ( _createPromptProvider ( ) ) ;
275
+ }
275
276
276
277
/**
277
278
* Execute the workflow, which will report the dry run events, run the tasks, and complete
@@ -337,6 +338,8 @@ function getUsage(): string {
337
338
--list-schematics List all schematics from the collection, by name. A collection name
338
339
should be suffixed by a colon. Example: '@schematics/schematics:'.
339
340
341
+ --no-interactive Disables interactive input prompts.
342
+
340
343
--verbose Show more information.
341
344
342
345
--help Show this message.
@@ -357,6 +360,7 @@ const booleanArgs = [
357
360
'list-schematics' ,
358
361
'listSchematics' ,
359
362
'verbose' ,
363
+ 'interactive' ,
360
364
] ;
361
365
362
366
function parseArgs ( args : string [ ] | undefined ) : minimist . ParsedArgs {
@@ -368,13 +372,29 @@ function parseArgs(args: string[] | undefined): minimist.ParsedArgs {
368
372
'allowPrivate' : 'allow-private' ,
369
373
} ,
370
374
default : {
375
+ 'interactive' : true ,
371
376
'debug' : null ,
372
377
'dryRun' : null ,
373
378
} ,
374
379
'--' : true ,
375
380
} ) ;
376
381
}
377
382
383
+ function isTTY ( ) : boolean {
384
+ const isTruthy = ( value : undefined | string ) = > {
385
+ // Returns true if value is a string that is anything but 0 or false.
386
+ return value !== undefined && value !== '0' && value . toUpperCase ( ) !== 'FALSE' ;
387
+ } ;
388
+
389
+ // If we force TTY, we always return true.
390
+ const force = process . env [ 'NG_FORCE_TTY' ] ;
391
+ if ( force !== undefined ) {
392
+ return isTruthy ( force ) ;
393
+ }
394
+
395
+ return ! ! process . stdout . isTTY && ! isTruthy ( process . env [ 'CI' ] ) ;
396
+ }
397
+
378
398
if ( require . main === module ) {
379
399
const args = process . argv . slice ( 2 ) ;
380
400
main ( { args } )
0 commit comments