|
3 | 3 | using System.IO;
|
4 | 4 | using System.Linq;
|
5 | 5 | using System.Text;
|
| 6 | +using WebCompiler.Helpers; |
6 | 7 |
|
7 | 8 | namespace WebCompiler
|
8 | 9 | {
|
@@ -32,18 +33,30 @@ public IEnumerable<CompilerResult> Process(string configFile, IEnumerable<Config
|
32 | 33 | try
|
33 | 34 | {
|
34 | 35 | FileInfo info = new FileInfo(configFile);
|
| 36 | + string directory = info.Directory.FullName; |
35 | 37 | configs = configs ?? ConfigHandler.GetConfigs(configFile);
|
36 | 38 |
|
37 | 39 | if (configs.Any())
|
38 | 40 | OnConfigProcessed(configs.First(), 0, configs.Count());
|
39 | 41 |
|
| 42 | + int i = 0; |
40 | 43 | foreach (Config config in configs)
|
41 | 44 | {
|
| 45 | + ++i; |
| 46 | + |
42 | 47 | if (force || config.CompilationRequired())
|
43 | 48 | {
|
44 |
| - var result = ProcessConfig(info.Directory.FullName, config); |
45 |
| - list.Add(result); |
46 |
| - OnConfigProcessed(config, list.Count, configs.Count()); |
| 49 | + if (GlobHelper.IsGlobPattern(config.InputFile)) |
| 50 | + { |
| 51 | + foreach (Config matchedConfig in config.Match(directory)) |
| 52 | + list.Add(ProcessConfig(directory, matchedConfig)); |
| 53 | + } |
| 54 | + else |
| 55 | + { |
| 56 | + list.Add(ProcessConfig(directory, config)); |
| 57 | + } |
| 58 | + |
| 59 | + OnConfigProcessed(config, i, configs.Count()); |
47 | 60 | }
|
48 | 61 | }
|
49 | 62 | }
|
@@ -112,12 +125,11 @@ private IEnumerable<CompilerResult> SourceFileChanged(string configFile,
|
112 | 125 | // Compile if the file if it's referenced directly in compilerconfig.json
|
113 | 126 | foreach (Config config in configs)
|
114 | 127 | {
|
115 |
| - string input = Path.Combine(folder, config.InputFile.Replace("/", "\\")); |
116 |
| - |
117 |
| - if (input.Equals(sourceFile, StringComparison.OrdinalIgnoreCase)) |
| 128 | + Config matchingConfig = config.Match(folder, sourceFile); |
| 129 | + if (matchingConfig != null) |
118 | 130 | {
|
119 |
| - list.Add(ProcessConfig(folder, config)); |
120 |
| - compiledFiles.Add(input.ToLowerInvariant()); |
| 131 | + list.Add(ProcessConfig(folder, matchingConfig)); |
| 132 | + compiledFiles.Add(matchingConfig.InputFile.ToLowerInvariant()); |
121 | 133 | }
|
122 | 134 | }
|
123 | 135 |
|
|
0 commit comments