@@ -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,29 @@ function createReferenceFile() {
20
25
}
21
26
}
22
27
23
- function createTsconfig ( ) {
24
- var tsconfigPath = path . join ( projectDir , 'tsconfig.json' ) ;
28
+ function migrateTsconfig ( tsconfigPath ) {
29
+ var displaybleTsconfigPath = path . relative ( projectDir , tsconfigPath ) ;
30
+
31
+ try {
32
+ var existingConfigContents = fs . readFileSync ( tsconfigPath ) ;
33
+ var existingConfig = JSON . parse ( existingConfigContents ) ;
34
+ } catch ( e ) {
35
+ console . error ( "Invalid " + displaybleTsconfigPath + ": " + e ) ;
36
+ return ;
37
+ }
38
+
39
+ if ( existingConfig [ "compilerOptions" ] ) {
40
+ if ( "sourceMap" in existingConfig [ "compilerOptions" ] ) {
41
+ delete existingConfig [ "compilerOptions" ] [ "sourceMap" ] ;
42
+ console . warn ( "> Deleted \"compilerOptions.sourceMap\" setting in \"" + displaybleTsconfigPath + "\"." ) ;
43
+ console . warn ( "> Inline source maps will be used when building in Debug configuration from now on." ) ;
44
+ }
45
+ }
46
+
47
+ fs . writeFileSync ( tsconfigPath , JSON . stringify ( existingConfig , null , 4 ) ) ;
48
+ }
49
+
50
+ function createTsconfig ( tsconfigPath ) {
25
51
var tsconfig = { } ;
26
52
27
53
tsconfig . compilerOptions = {
@@ -35,9 +61,7 @@ function createTsconfig() {
35
61
36
62
tsconfig . exclude = [ 'node_modules' , 'platforms' , "**/*.aot.ts" ] ;
37
63
38
- if ( ! fs . existsSync ( tsconfigPath ) ) {
39
- fs . appendFileSync ( tsconfigPath , JSON . stringify ( tsconfig , null , 4 ) ) ;
40
- }
64
+ fs . writeFileSync ( tsconfigPath , JSON . stringify ( tsconfig , null , 4 ) ) ;
41
65
}
42
66
43
67
function getProjectTypeScriptVersion ( ) {
0 commit comments