@@ -10,8 +10,8 @@ internal class IcedCoffeeScriptCompiler : ICompiler
10
10
{
11
11
private static Regex _errorRx = new Regex ( ":(?<line>[0-9]+):(?<column>[0-9]+).*error: (?<message>.+)" , RegexOptions . Compiled ) ;
12
12
private string _path ;
13
- private string _output = string . Empty ;
14
13
private string _error = string . Empty ;
14
+ private string _temp = Path . Combine ( Path . GetTempPath ( ) , ".iced-coffee-script" ) ;
15
15
16
16
public IcedCoffeeScriptCompiler ( string path )
17
17
{
@@ -36,7 +36,19 @@ public CompilerResult Compile(Config config)
36
36
{
37
37
RunCompilerProcess ( config , info ) ;
38
38
39
- result . CompiledContent = _output ;
39
+ string tempFile = Path . ChangeExtension ( Path . Combine ( _temp , info . Name ) , ".js" ) ;
40
+
41
+ if ( File . Exists ( tempFile ) )
42
+ {
43
+ result . CompiledContent = File . ReadAllText ( tempFile ) ;
44
+
45
+ if ( config . SourceMap )
46
+ {
47
+ string mapFile = tempFile + ".map" ;
48
+ if ( File . Exists ( mapFile ) )
49
+ result . SourceMap = File . ReadAllText ( mapFile ) ;
50
+ }
51
+ }
40
52
41
53
if ( _error . Length > 0 )
42
54
{
@@ -86,29 +98,25 @@ private void RunCompilerProcess(Config config, FileInfo info)
86
98
CreateNoWindow = true ,
87
99
FileName = "cmd.exe" ,
88
100
Arguments = $ "/c \" \" { Path . Combine ( _path , "node_modules\\ .bin\\ iced.cmd" ) } \" { arguments } \" { info . FullName } \" \" ",
89
- StandardOutputEncoding = Encoding . UTF8 ,
90
101
StandardErrorEncoding = Encoding . UTF8 ,
91
- RedirectStandardOutput = true ,
92
102
RedirectStandardError = true ,
93
103
} ;
94
104
95
105
start . EnvironmentVariables [ "PATH" ] = _path + ";" + start . EnvironmentVariables [ "PATH" ] ;
96
106
97
107
Process p = Process . Start ( start ) ;
98
- var stdout = p . StandardOutput . ReadToEndAsync ( ) ;
99
108
var stderr = p . StandardError . ReadToEndAsync ( ) ;
100
109
p . WaitForExit ( ) ;
101
110
102
- _output = stdout . Result ;
103
111
_error = stderr . Result ;
104
112
}
105
113
106
- private static string ConstructArguments ( Config config )
114
+ private string ConstructArguments ( Config config )
107
115
{
108
- string arguments = " --print " ;
116
+ string arguments = $ " --compile --output \" { _temp } \" ";
109
117
110
- // if (config.SourceMap)
111
- // arguments += " --source- map-map-inline ";
118
+ if ( config . SourceMap )
119
+ arguments += " --map" ;
112
120
113
121
IcedCoffeeScriptOptions options = new IcedCoffeeScriptOptions ( config ) ;
114
122
0 commit comments