File tree 1 file changed +6
-7
lines changed
1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change 1
- // tslint:disable no-unnecessary-type-assertion (TODO: tslint can't find node types)
2
-
3
1
namespace ts . server . typingsInstaller {
4
2
const fs : {
5
3
appendFileSync ( file : string , content : string ) : void
@@ -12,19 +10,20 @@ namespace ts.server.typingsInstaller {
12
10
} = require ( "path" ) ;
13
11
14
12
class FileLog implements Log {
15
- private logEnabled = true ;
16
- constructor ( private readonly logFile ?: string ) {
13
+ constructor ( private logFile : string | undefined ) {
17
14
}
18
15
19
16
isEnabled = ( ) => {
20
- return this . logEnabled && this . logFile !== undefined ;
17
+ return typeof this . logFile === "string" ;
21
18
}
22
19
writeLine = ( text : string ) => {
20
+ if ( typeof this . logFile !== "string" ) return ;
21
+
23
22
try {
24
- fs . appendFileSync ( this . logFile ! , `[${ nowString ( ) } ] ${ text } ${ sys . newLine } ` ) ; // TODO: GH#18217
23
+ fs . appendFileSync ( this . logFile , `[${ nowString ( ) } ] ${ text } ${ sys . newLine } ` ) ;
25
24
}
26
25
catch ( e ) {
27
- this . logEnabled = false ;
26
+ this . logFile = undefined ;
28
27
}
29
28
}
30
29
}
You can’t perform that action at this time.
0 commit comments