11import  chalk  from  'chalk' ; 
2+ import  {  type  PatchPulseConfig  }  from  '../../services/config' ; 
23import  {  type  DependencyInfo  }  from  '../../types' ; 
34import  {  pluralize  }  from  '../../utils/pluralize' ; 
45import  {  displayHelp  }  from  './help' ; 
@@ -22,9 +23,12 @@ export interface UpdateOptions {
2223 * @param  _wasPaused - The original paused state (unused but kept for consistency) 
2324 */ 
2425function  setupRawMode ( stdin : typeof  process . stdin )  { 
25-   stdin . setRawMode ( true ) ; 
26-   stdin . resume ( ) ; 
27-   stdin . setEncoding ( 'utf8' ) ; 
26+   // Check if stdin is a TTY before calling setRawMode 
27+   if  ( stdin . isTTY )  { 
28+     stdin . setRawMode ( true ) ; 
29+     stdin . resume ( ) ; 
30+     stdin . setEncoding ( 'utf8' ) ; 
31+   } 
2832} 
2933
3034/** 
@@ -42,20 +46,24 @@ function restoreTerminalSettings({
4246  wasRaw : boolean ; 
4347  wasPaused : boolean ; 
4448} )  { 
45-   stdin . setRawMode ( wasRaw ) ; 
46-   if  ( wasPaused )  { 
47-     stdin . pause ( ) ; 
49+   // Only call setRawMode if stdin is a TTY 
50+   if  ( stdin . isTTY )  { 
51+     stdin . setRawMode ( wasRaw ) ; 
52+     if  ( wasPaused )  { 
53+       stdin . pause ( ) ; 
54+     } 
4855  } 
4956} 
5057
5158/** 
5259 * Displays the interactive update prompt after the summary 
5360 * @param  dependencies - Array of outdated dependencies 
54-  * @param  packageManager  - The detected package manager  
61+  * @param  config  - The configuration object  
5562 * @returns  Promise that resolves with the selected update type or null if cancelled 
5663 */ 
5764export  function  displayUpdatePrompt ( 
58-   dependencies : DependencyInfo [ ] 
65+   dependencies : DependencyInfo [ ] , 
66+   config ?: PatchPulseConfig 
5967) : Promise < 'patch'  |  'minor'  |  'all'  |  null >  { 
6068  return  new  Promise ( resolve  =>  { 
6169    const  outdatedDeps  =  dependencies . filter ( d  =>  d . isOutdated  &&  ! d . isSkipped ) ; 
@@ -65,6 +73,26 @@ export function displayUpdatePrompt(
6573      return ; 
6674    } 
6775
76+     // Check if update prompt is disabled via config 
77+     if  ( config ?. noUpdatePrompt )  { 
78+       resolve ( null ) ; 
79+       return ; 
80+     } 
81+ 
82+     // Check if we're in a non-interactive environment (CI/CD) 
83+     if  ( ! process . stdin . isTTY )  { 
84+       console . log ( 
85+         chalk . yellow ( 
86+           '⚠️  Running in non-interactive environment. Skipping update prompt.' 
87+         ) 
88+       ) ; 
89+       console . log ( 
90+         chalk . gray ( 'Use --update-prompt flag to force interactive mode.' ) 
91+       ) ; 
92+       resolve ( null ) ; 
93+       return ; 
94+     } 
95+ 
6896    const  updateOptions  =  categorizeUpdates ( outdatedDeps ) ; 
6997
7098    function  showOptions ( )  { 
0 commit comments