@@ -21,8 +21,8 @@ class MdTail {
2121 return { showHelp : false } ;
2222 }
2323
24- expandFiles ( args , currentDir ) {
25- this . files = this . fileManager . expandFiles ( args , currentDir ) ;
24+ async expandFiles ( args , currentDir ) {
25+ this . files = await this . fileManager . expandFiles ( args , currentDir ) ;
2626 return this . files ;
2727 }
2828
@@ -50,11 +50,11 @@ class MdTail {
5050 return this . display . formatContent ( content , filename ) ;
5151 }
5252
53- displayCurrentFile ( ) {
53+ async displayCurrentFile ( ) {
5454 const currentFile = this . files [ this . currentTabIndex ] ;
5555
5656 try {
57- const content = this . fileManager . readFile ( currentFile ) ;
57+ const content = await this . fileManager . readFile ( currentFile ) ;
5858 const filename = path . basename ( currentFile ) ;
5959
6060 this . display . render ( content , filename , this . files , this . currentTabIndex ) ;
@@ -107,44 +107,44 @@ Examples:
107107 process . stdin . setRawMode ( true ) ;
108108 process . stdin . resume ( ) ;
109109
110- process . stdin . on ( 'keypress' , ( str , key ) => {
110+ process . stdin . on ( 'keypress' , async ( str , key ) => {
111111 if ( key && key . ctrl && key . name === 'c' ) {
112- this . cleanup ( ) ;
112+ await this . cleanup ( ) ;
113113 process . exit ( 0 ) ;
114114 }
115115
116116 if ( this . files . length > 1 ) {
117117 if ( key && key . name === 'left' ) {
118118 this . navigateTab ( 'left' ) ;
119- this . displayCurrentFile ( ) ;
119+ await this . displayCurrentFile ( ) ;
120120 } else if ( key && key . name === 'right' ) {
121121 this . navigateTab ( 'right' ) ;
122- this . displayCurrentFile ( ) ;
122+ await this . displayCurrentFile ( ) ;
123123 }
124124 }
125125 } ) ;
126126 }
127127
128- startWatching ( ) {
128+ async startWatching ( ) {
129129 // Setup keyboard navigation
130130 this . setupKeyboardNavigation ( ) ;
131131
132132 // Initial display
133- this . displayCurrentFile ( ) ;
133+ await this . displayCurrentFile ( ) ;
134134
135135 // Watch each file
136- this . fileManager . startWatching ( this . files , ( fileIndex ) => {
136+ this . fileManager . startWatching ( this . files , async ( fileIndex ) => {
137137 // Only redraw if we're viewing the changed file or if there's only one file
138138 if ( fileIndex === this . currentTabIndex || this . files . length === 1 ) {
139- this . displayCurrentFile ( ) ;
139+ await this . displayCurrentFile ( ) ;
140140 }
141141 } ) ;
142142
143143 // Show initial file list
144144 if ( this . files . length > 1 ) {
145145 this . display . showFileList ( this . files . length ) ;
146- setTimeout ( ( ) => {
147- this . displayCurrentFile ( ) ;
146+ setTimeout ( async ( ) => {
147+ await this . displayCurrentFile ( ) ;
148148 } , 1500 ) ;
149149 }
150150 }
@@ -153,7 +153,7 @@ Examples:
153153 this . fileManager . stopWatching ( this . files ) ;
154154 }
155155
156- cleanup ( ) {
156+ async cleanup ( ) {
157157 if ( process . stdin . isTTY ) {
158158 process . stdin . setRawMode ( false ) ;
159159 }
@@ -162,7 +162,7 @@ Examples:
162162 this . stopWatching ( ) ;
163163 }
164164
165- run ( args ) {
165+ async run ( args ) {
166166 // Parse arguments
167167 const options = this . parseArguments ( args ) ;
168168
@@ -172,7 +172,7 @@ Examples:
172172 }
173173
174174 // Expand and validate files
175- const files = this . expandFiles ( args ) ;
175+ const files = await this . expandFiles ( args ) ;
176176
177177 try {
178178 this . validateFiles ( files ) ;
@@ -183,13 +183,13 @@ Examples:
183183 }
184184
185185 // Setup exit handlers
186- process . on ( 'SIGINT' , ( ) => {
187- this . cleanup ( ) ;
186+ process . on ( 'SIGINT' , async ( ) => {
187+ await this . cleanup ( ) ;
188188 process . exit ( 0 ) ;
189189 } ) ;
190190
191191 // Start watching
192- this . startWatching ( ) ;
192+ await this . startWatching ( ) ;
193193 }
194194}
195195
0 commit comments