Skip to content

Commit 4c60095

Browse files
Added file processing flag. Fixed #70
1 parent 20cac62 commit 4c60095

File tree

3 files changed

+26
-19
lines changed

3 files changed

+26
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- [x] LESS: Added relative URL compiler support (#63)
66
- [x] Use the official CoffeeScript compiler (#68)
77
- [x] Enable source maps for Iced CoffeeScript
8+
- [x] Compile up the LESS @import chain (#67)
89
- [ ] Generate gulpfile.js from compilerconfig.json (#34)
910
- [ ] Preview window (#6)
1011
- [ ] File globbing pattern support (#49)

src/WebCompiler/Config/ConfigFileProcessor.cs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,40 @@ namespace WebCompiler
1111
/// </summary>
1212
public class ConfigFileProcessor
1313
{
14+
private static List<string> _processing = new List<string>();
15+
1416
/// <summary>
1517
/// Parses a compiler config file and runs the configured compilers.
1618
/// </summary>
1719
/// <param name="configFile">The absolute or relative file path to compilerconfig.json</param>
1820
/// <returns>A list of compiler results.</returns>
1921
public IEnumerable<CompilerResult> Process(string configFile)
2022
{
21-
FileInfo info = new FileInfo(configFile);
22-
var configs = ConfigHandler.GetConfigs(configFile);
23+
if (_processing.Contains(configFile))
24+
return Enumerable.Empty<CompilerResult>();
25+
26+
_processing.Add(configFile);
2327
List<CompilerResult> list = new List<CompilerResult>();
2428

25-
if (configs.Any())
26-
OnConfigProcessed(configs.First(), 0, configs.Count());
29+
try
30+
{
31+
FileInfo info = new FileInfo(configFile);
32+
var configs = ConfigHandler.GetConfigs(configFile);
33+
34+
if (configs.Any())
35+
OnConfigProcessed(configs.First(), 0, configs.Count());
2736

28-
foreach (Config config in configs)
37+
foreach (Config config in configs)
38+
{
39+
var result = ProcessConfig(info.Directory.FullName, config);
40+
list.Add(result);
41+
OnConfigProcessed(config, list.Count, configs.Count());
42+
}
43+
}
44+
finally
2945
{
30-
var result = ProcessConfig(info.Directory.FullName, config);
31-
list.Add(result);
32-
OnConfigProcessed(config, list.Count, configs.Count());
46+
if (_processing.Contains(configFile))
47+
_processing.Remove(configFile);
3348
}
3449

3550
return list;

src/WebCompilerVsix/CompilerService.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
using System;
22
using System.IO;
3-
using System.Threading;
43
using System.Linq;
4+
using System.Threading;
55
using System.Windows.Forms;
66
using System.Windows.Threading;
7-
using EnvDTE;
87
using EnvDTE80;
98
using WebCompiler;
109

@@ -58,8 +57,6 @@ public static void Process(string configFile)
5857
{
5958
try
6059
{
61-
_dte.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationBuild);
62-
6360
var result = Processor.Process(configFile);
6461
ErrorListService.ProcessCompilerResults(result, configFile);
6562

@@ -85,7 +82,6 @@ public static void Process(string configFile)
8582
}
8683
finally
8784
{
88-
_dte.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationBuild);
8985
_dte.StatusBar.Progress(false);
9086
}
9187
});
@@ -97,7 +93,6 @@ public static void SourceFileChanged(string configFile, string sourceFile)
9793
{
9894
try
9995
{
100-
_dte.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationBuild);
10196
StatusText($"Compiling \"{Path.GetFileName(sourceFile)}\"...");
10297

10398
var result = Processor.SourceFileChanged(configFile, sourceFile);
@@ -113,10 +108,6 @@ public static void SourceFileChanged(string configFile, string sourceFile)
113108
Logger.Log(ex);
114109
ShowError(configFile);
115110
}
116-
finally
117-
{
118-
_dte.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationBuild);
119-
}
120111
});
121112
}
122113

@@ -130,7 +121,7 @@ private static void StatusText(string message)
130121

131122
private static void ShowError(string configFile)
132123
{
133-
MessageBox.Show($"There is an error in the {Constants.CONFIG_FILENAME} file. This could be due to a change in the format after this extension was updated.", Constants.VSIX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Information);
124+
MessageBox.Show($"There is an error in the {Constants.CONFIG_FILENAME} file. This could be due to a change in the format after this extension was updated.", Constants.VSIX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
134125

135126
if (File.Exists(configFile))
136127
WebCompilerPackage._dte.ItemOperations.OpenFile(configFile);

0 commit comments

Comments
 (0)