@@ -80,8 +80,13 @@ private static int Wain(string[] args)
80
80
{
81
81
int exitCode = 0 ;
82
82
if ( ! string . IsNullOrWhiteSpace ( code . Value ) )
83
- {
84
- exitCode = await RunCode ( code . Value , debugMode . HasValue ( ) , app . RemainingArguments . Concat ( argsAfterDoubleHypen ) , cwd . Value ( ) ) ;
83
+ {
84
+ var optimizationLevel = OptimizationLevel . Debug ;
85
+ if ( configuration . HasValue ( ) && configuration . Value ( ) . ToLower ( ) == "release" )
86
+ {
87
+ optimizationLevel = OptimizationLevel . Release ;
88
+ }
89
+ exitCode = await RunCode ( code . Value , debugMode . HasValue ( ) , optimizationLevel , app . RemainingArguments . Concat ( argsAfterDoubleHypen ) , cwd . Value ( ) ) ;
85
90
}
86
91
return exitCode ;
87
92
} ) ;
@@ -145,8 +150,8 @@ private static async Task<int> RunScript(string file, bool debugMode, Optimizati
145
150
if ( IsHttpUri ( file ) )
146
151
{
147
152
var downloader = new ScriptDownloader ( ) ;
148
- var scriptFile = await downloader . Download ( file ) ;
149
- var exitCode = await RunScript ( scriptFile , debugMode , optimizationLevel , args , interactive ) ;
153
+ var scriptFile = await downloader . Download ( file ) ;
154
+ var exitCode = await RunScript ( scriptFile , debugMode , optimizationLevel , args , interactive ) ;
150
155
File . Delete ( scriptFile ) ;
151
156
return exitCode ;
152
157
}
@@ -186,10 +191,10 @@ private static async Task RunInteractive(bool debugMode)
186
191
await runner . RunLoop ( ) ;
187
192
}
188
193
189
- private static Task < int > RunCode ( string code , bool debugMode , IEnumerable < string > args , string currentWorkingDirectory )
194
+ private static Task < int > RunCode ( string code , bool debugMode , OptimizationLevel optimizationLevel , IEnumerable < string > args , string currentWorkingDirectory )
190
195
{
191
196
var sourceText = SourceText . From ( code ) ;
192
- var context = new ScriptContext ( sourceText , currentWorkingDirectory ?? Directory . GetCurrentDirectory ( ) , args , null , scriptMode : ScriptMode . Eval ) ;
197
+ var context = new ScriptContext ( sourceText , currentWorkingDirectory ?? Directory . GetCurrentDirectory ( ) , args , null , optimizationLevel , ScriptMode . Eval ) ;
193
198
return Run ( debugMode , context ) ;
194
199
}
195
200
0 commit comments