@@ -6,7 +6,12 @@ var path = require('path');
66
77var projectDir = hook . findProjectDir ( ) ;
88if ( projectDir ) {
9- createTsconfig ( ) ;
9+ var tsconfigPath = path . join ( projectDir , 'tsconfig.json' ) ;
10+ if ( fs . existsSync ( tsconfigPath ) ) {
11+ migrateTsconfig ( tsconfigPath ) ;
12+ } else {
13+ createTsconfig ( tsconfigPath ) ;
14+ }
1015 createReferenceFile ( ) ;
1116 installTypescript ( ) ;
1217}
@@ -20,8 +25,27 @@ function createReferenceFile() {
2025 }
2126}
2227
23- function createTsconfig ( ) {
24- var tsconfigPath = path . join ( projectDir , 'tsconfig.json' ) ;
28+ function migrateTsconfig ( tsconfigPath ) {
29+ try {
30+ var existingConfigContents = fs . readFileSync ( tsconfigPath ) ;
31+ var existingConfig = JSON . parse ( existingConfigContents ) ;
32+ } catch ( e ) {
33+ console . error ( "Invalid " + tsconfigPath + ": " + e ) ;
34+ return ;
35+ }
36+
37+ if ( existingConfig [ "compilerOptions" ] ) {
38+ if ( "sourceMap" in existingConfig [ "compilerOptions" ] ) {
39+ delete existingConfig [ "compilerOptions" ] [ "sourceMap" ] ;
40+ console . warn ( "> Deleted \"compilerOptions.sourceMap\" setting in \"" + tsconfigPath + "\"." ) ;
41+ console . warn ( "> Inline source maps will be used when building in Debug configuration from now on." ) ;
42+ }
43+ }
44+
45+ fs . writeFileSync ( tsconfigPath , JSON . stringify ( existingConfig , null , 4 ) ) ;
46+ }
47+
48+ function createTsconfig ( tsconfigPath ) {
2549 var tsconfig = { } ;
2650
2751 tsconfig . compilerOptions = {
@@ -35,9 +59,7 @@ function createTsconfig() {
3559
3660 tsconfig . exclude = [ 'node_modules' , 'platforms' , "**/*.aot.ts" ] ;
3761
38- if ( ! fs . existsSync ( tsconfigPath ) ) {
39- fs . appendFileSync ( tsconfigPath , JSON . stringify ( tsconfig , null , 4 ) ) ;
40- }
62+ fs . writeFileSync ( tsconfigPath , JSON . stringify ( tsconfig , null , 4 ) ) ;
4163}
4264
4365function getProjectTypeScriptVersion ( ) {
0 commit comments