@@ -56,6 +56,7 @@ export class CompileTabLogic {
56
56
if ( this . language != null ) {
57
57
this . compiler . set ( 'language' , this . language )
58
58
}
59
+
59
60
}
60
61
61
62
setOptimize ( newOptimizeValue : boolean ) {
@@ -64,9 +65,11 @@ export class CompileTabLogic {
64
65
this . compiler . set ( 'optimize' , this . optimize )
65
66
}
66
67
67
- setUseFileConfiguration ( useFileConfiguration : boolean ) {
68
+ async setUseFileConfiguration ( useFileConfiguration : boolean ) {
68
69
this . useFileConfiguration = useFileConfiguration
70
+ console . log ( 'setUseFileConfiguration' , useFileConfiguration )
69
71
this . compiler . set ( 'useFileConfiguration' , useFileConfiguration )
72
+ await this . setCompilerConfigContent ( )
70
73
}
71
74
72
75
setConfigFilePath ( path ) {
@@ -85,7 +88,10 @@ export class CompileTabLogic {
85
88
this . compiler . set ( 'evmVersion' , this . evmVersion )
86
89
}
87
90
88
- getCompilerState ( ) {
91
+ async getCompilerState ( ) {
92
+ await this . setCompilerMappings ( )
93
+ await this . setCompilerConfigContent ( )
94
+ console . log ( 'getCompilerState' , this . compiler )
89
95
return this . compiler . state
90
96
}
91
97
@@ -99,6 +105,23 @@ export class CompileTabLogic {
99
105
this . compiler . set ( 'language' , lang )
100
106
}
101
107
108
+ async setCompilerMappings ( ) {
109
+ if ( await this . api . fileExists ( 'remappings.txt' ) ) {
110
+ this . api . readFile ( 'remappings.txt' ) . then ( remappings => {
111
+ this . compiler . set ( 'remappings' , remappings . split ( '\n' ) . filter ( Boolean ) )
112
+ } )
113
+ } else this . compiler . set ( 'remappings' , [ ] )
114
+ }
115
+
116
+ async setCompilerConfigContent ( ) {
117
+ if ( this . configFilePath && this . useFileConfiguration ) {
118
+ this . api . readFile ( this . configFilePath ) . then ( content => {
119
+ this . compiler . set ( 'configFileContent' , content )
120
+ } )
121
+ }
122
+ }
123
+
124
+
102
125
/**
103
126
* Compile a specific file of the file manager
104
127
* @param {string } target the path to the file to compile
@@ -110,16 +133,8 @@ export class CompileTabLogic {
110
133
const sources = { [ target ] : { content } }
111
134
this . event . emit ( 'removeAnnotations' )
112
135
this . event . emit ( 'startingCompilation' )
113
- if ( await this . api . fileExists ( 'remappings.txt' ) ) {
114
- this . api . readFile ( 'remappings.txt' ) . then ( remappings => {
115
- this . compiler . set ( 'remappings' , remappings . split ( '\n' ) . filter ( Boolean ) )
116
- } )
117
- } else this . compiler . set ( 'remappings' , [ ] )
118
- if ( this . configFilePath ) {
119
- this . api . readFile ( this . configFilePath ) . then ( contentConfig => {
120
- this . compiler . set ( 'configFileContent' , contentConfig )
121
- } )
122
- }
136
+ await this . setCompilerMappings ( )
137
+ await this . setCompilerConfigContent ( )
123
138
// setTimeout fix the animation on chrome... (animation triggered by 'staringCompilation')
124
139
setTimeout ( ( ) => { this . compiler . compile ( sources , target ) ; resolve ( true ) } , 100 )
125
140
} ) . catch ( ( error ) => {
0 commit comments