File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -284,10 +284,24 @@ module ts {
284284 * Read tsconfig.json file
285285 * @param fileName The path to the config file
286286 */
287- export function readConfigFile ( fileName : string ) : { config ?: any ; error ?: Diagnostic } {
287+ export function readConfigFile ( fileName : string ) : { config ?: any ; error ?: Diagnostic } {
288288 try {
289289 var text = sys . readFile ( fileName ) ;
290- return { config : / \S / . test ( text ) ? JSON . parse ( text ) : { } } ;
290+ return parseConfigFileText ( fileName , text ) ;
291+ }
292+ catch ( e ) {
293+ return { error : createCompilerDiagnostic ( Diagnostics . Cannot_read_file_0_Colon_1 , fileName , e . message ) } ;
294+ }
295+ }
296+
297+ /**
298+ * Parse the text of the tsconfig.json file
299+ * @param fileName The path to the config file
300+ * @param jsonText The text of the config file
301+ */
302+ export function parseConfigFileText ( fileName : string , jsonText : string ) : { config ?: any ; error ?: Diagnostic } {
303+ try {
304+ return { config : / \S / . test ( jsonText ) ? JSON . parse ( jsonText ) : { } } ;
291305 }
292306 catch ( e ) {
293307 return { error : createCompilerDiagnostic ( Diagnostics . Failed_to_parse_file_0_Colon_1 , fileName , e . message ) } ;
Original file line number Diff line number Diff line change @@ -804,7 +804,7 @@ module ts {
804804 ( ) => {
805805 let text = sourceTextSnapshot . getText ( 0 , sourceTextSnapshot . getLength ( ) ) ;
806806
807- let result = this . parseConfigFileText ( fileName , text ) ;
807+ let result = parseConfigFileText ( fileName , text ) ;
808808
809809 if ( result . error ) {
810810 return {
@@ -824,15 +824,6 @@ module ts {
824824 } ) ;
825825 }
826826
827- private parseConfigFileText ( fileName : string , jsonText : string ) : { config ?: any ; error ?: Diagnostic } {
828- try {
829- return { config : / \S / . test ( jsonText ) ? JSON . parse ( jsonText ) : { } } ;
830- }
831- catch ( e ) {
832- return { error : createCompilerDiagnostic ( Diagnostics . Failed_to_parse_file_0_Colon_1 , fileName , e . message ) } ;
833- }
834- }
835-
836827 public getDefaultCompilationSettings ( ) : string {
837828 return this . forwardJSONCall (
838829 "getDefaultCompilationSettings()" ,
You can’t perform that action at this time.
0 commit comments