@@ -6,7 +6,12 @@ var path = require('path');
6
6
7
7
var projectDir = hook . findProjectDir ( ) ;
8
8
if ( 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
+ }
10
15
createReferenceFile ( ) ;
11
16
installTypescript ( ) ;
12
17
}
@@ -20,8 +25,27 @@ function createReferenceFile() {
20
25
}
21
26
}
22
27
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 ) {
25
49
var tsconfig = { } ;
26
50
27
51
tsconfig . compilerOptions = {
@@ -35,9 +59,7 @@ function createTsconfig() {
35
59
36
60
tsconfig . exclude = [ 'node_modules' , 'platforms' , "**/*.aot.ts" ] ;
37
61
38
- if ( ! fs . existsSync ( tsconfigPath ) ) {
39
- fs . appendFileSync ( tsconfigPath , JSON . stringify ( tsconfig , null , 4 ) ) ;
40
- }
62
+ fs . writeFileSync ( tsconfigPath , JSON . stringify ( tsconfig , null , 4 ) ) ;
41
63
}
42
64
43
65
function getProjectTypeScriptVersion ( ) {
0 commit comments