Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions WebCompiler.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
# Visual Studio Version 18
VisualStudioVersion = 18.5.11716.220 stable
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebCompilerVsix", "src\WebCompilerVsix\WebCompilerVsix.csproj", "{49C270BE-9645-40D5-BE08-91ADE243D394}"
EndProject
Expand Down
10 changes: 5 additions & 5 deletions src/WebCompiler/Compile/BabelCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public BabelCompiler(string path)
_path = path;
}

public CompilerResult Compile(Config config)
public CompilerResult Compile(ConfigEntry config)
{
string baseFolder = Path.GetDirectoryName(config.FileName);
string inputFile = Path.Combine(baseFolder, config.InputFile);
Expand Down Expand Up @@ -75,7 +75,7 @@ public CompilerResult Compile(Config config)
return result;
}

private void RunCompilerProcess(Config config, FileInfo info)
private void RunCompilerProcess(ConfigEntry config, FileInfo info)
{
string arguments = ConstructArguments(config);

Expand Down Expand Up @@ -106,7 +106,7 @@ private void RunCompilerProcess(Config config, FileInfo info)
}
}

private static string ConstructArguments(Config config)
private static string ConstructArguments(ConfigEntry config)
{
//string relative = FileHelpers.MakeRelative(config.GetAbsoluteOutputFile().FullName, config.GetAbsoluteInputFile().FullName);
string arguments = $"--presets react --out-file \"\"";
Expand All @@ -115,8 +115,8 @@ private static string ConstructArguments(Config config)

if (options.SourceMap || config.SourceMap)
arguments += " --source-maps inline";
if (options.Compact.HasValue && !options.Compact.Value)
arguments += " --compact false";
if (options.Compact.HasValue)
arguments += " --compact " + (options.Compact.Value ? "true" : "false");

return arguments;
}
Expand Down
2 changes: 1 addition & 1 deletion src/WebCompiler/Compile/BabelOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public BabelOptions()
/// <summary>
/// Load the settings from the config object
/// </summary>
protected override void LoadSettings(Config config)
protected override void LoadSettings(ConfigEntry config)
{
base.LoadSettings(config);
}
Expand Down
32 changes: 29 additions & 3 deletions src/WebCompiler/Compile/BaseOptions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using WebCompiler.Config;

namespace WebCompiler
{
Expand All @@ -13,10 +15,34 @@ namespace WebCompiler
/// <summary>
/// Loads the options based on the config object
/// </summary>
public static T FromConfig(Config config)
public static T FromConfig(ConfigEntry config)
{
ConfigMsBuild msBuildConfig = config as ConfigMsBuild;
string defaultFile = config.FileName + ".defaults";

if (msBuildConfig != null)
{
List<string> configsToTry = new List<string> {
defaultFile.Replace(".defaults", $".{msBuildConfig.Configuration}"),
defaultFile,
};
if (!string.IsNullOrEmpty(msBuildConfig.StartupDirectory))
{
configsToTry.Add($"{msBuildConfig.StartupDirectory}\\" +
defaultFile.Replace(".defaults", $".{msBuildConfig.Configuration}"));
configsToTry.Add($"{msBuildConfig.StartupDirectory}\\{defaultFile}");
}

foreach(string fileToTry in configsToTry)
{
if (File.Exists(fileToTry))
{
defaultFile = fileToTry;
break;
}
}
}

T options = new T();

if (File.Exists(defaultFile))
Expand Down Expand Up @@ -48,7 +74,7 @@ public static T FromConfig(Config config)
/// <summary>
/// Load the settings from the config object
/// </summary>
protected virtual void LoadSettings(Config config)
protected virtual void LoadSettings(ConfigEntry config)
{
var sourceMap = GetValue(config, "sourceMap");
if (sourceMap != null)
Expand All @@ -64,7 +90,7 @@ protected virtual void LoadSettings(Config config)
/// <summary>
/// Gets a value from a string keyed dictionary
/// </summary>
protected string GetValue(Config config, string key)
protected string GetValue(ConfigEntry config, string key)
{
if (config.Options.ContainsKey(key))
return config.Options[key].ToString();
Expand Down
4 changes: 2 additions & 2 deletions src/WebCompiler/Compile/CompilerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace WebCompiler
/// </summary>
public static class CompilerService
{
internal const string Version = "1.14.15";
internal const string Version = "1.14.17";
private static readonly string _path = Path.Combine(Path.GetTempPath(), "WebCompiler" + Version);
private static object _syncRoot = new object(); // Used to lock on the initialize step

Expand All @@ -29,7 +29,7 @@ public static bool IsSupported(string inputFile)
return AllowedExtensions.Contains(ext);
}

internal static ICompiler GetCompiler(Config config)
internal static ICompiler GetCompiler(ConfigEntry config)
{
string ext = Path.GetExtension(config.InputFile).ToUpperInvariant();
ICompiler compiler = null;
Expand Down
2 changes: 1 addition & 1 deletion src/WebCompiler/Compile/CssRelativePathAdjuster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ static class CssRelativePath
{
private static readonly Regex _rxUrl = new Regex(@"url\s*\(\s*([""']?)([^:)]+)\1\s*\)", RegexOptions.IgnoreCase | RegexOptions.Compiled);

public static string Adjust(string content, Config config)
public static string Adjust(string content, ConfigEntry config)
{
string cssFileContents = content;
string absoluteOutputPath = config.GetAbsoluteOutputFile().FullName;
Expand Down
6 changes: 3 additions & 3 deletions src/WebCompiler/Compile/HandlebarsCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public HandlebarsCompiler(string path)
_path = path;
}

public CompilerResult Compile(Config config)
public CompilerResult Compile(ConfigEntry config)
{
string baseFolder = Path.GetDirectoryName(config.FileName);
string inputFile = Path.Combine(baseFolder, config.InputFile);
Expand Down Expand Up @@ -121,7 +121,7 @@ public CompilerResult Compile(Config config)
return result;
}

private void RunCompilerProcess(Config config, FileInfo info)
private void RunCompilerProcess(ConfigEntry config, FileInfo info)
{
string arguments = ConstructArguments(config);

Expand Down Expand Up @@ -152,7 +152,7 @@ private void RunCompilerProcess(Config config, FileInfo info)
}
}

private string ConstructArguments(Config config)
private string ConstructArguments(ConfigEntry config)
{
string arguments = "";

Expand Down
2 changes: 1 addition & 1 deletion src/WebCompiler/Compile/HandlebarsOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public HandlebarsOptions()
/// <summary>
/// Load the settings from the config object
/// </summary>
protected override void LoadSettings(Config config)
protected override void LoadSettings(ConfigEntry config)
{
base.LoadSettings(config);

Expand Down
2 changes: 1 addition & 1 deletion src/WebCompiler/Compile/ICompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
{
internal interface ICompiler
{
CompilerResult Compile(Config config);
CompilerResult Compile(ConfigEntry config);
}
}
6 changes: 3 additions & 3 deletions src/WebCompiler/Compile/IcedCoffeeScriptCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public IcedCoffeeScriptCompiler(string path)
_path = path;
}

public CompilerResult Compile(Config config)
public CompilerResult Compile(ConfigEntry config)
{
string baseFolder = Path.GetDirectoryName(config.FileName);
string inputFile = Path.Combine(baseFolder, config.InputFile);
Expand Down Expand Up @@ -93,7 +93,7 @@ public CompilerResult Compile(Config config)
return result;
}

private void RunCompilerProcess(Config config, FileInfo info)
private void RunCompilerProcess(ConfigEntry config, FileInfo info)
{
string arguments = ConstructArguments(config);

Expand All @@ -120,7 +120,7 @@ private void RunCompilerProcess(Config config, FileInfo info)
}
}

private string ConstructArguments(Config config)
private string ConstructArguments(ConfigEntry config)
{
string arguments = $" --compile --output \"{_temp}\"";

Expand Down
2 changes: 1 addition & 1 deletion src/WebCompiler/Compile/IcedCoffeeScriptOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public IcedCoffeeScriptOptions()
/// <summary>
/// Loads the settings based on the config
/// </summary>
protected override void LoadSettings(Config config)
protected override void LoadSettings(ConfigEntry config)
{
base.LoadSettings(config);

Expand Down
6 changes: 3 additions & 3 deletions src/WebCompiler/Compile/LessCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public LessCompiler(string path)
_path = path;
}

public CompilerResult Compile(Config config)
public CompilerResult Compile(ConfigEntry config)
{
string baseFolder = Path.GetDirectoryName(config.FileName);
string inputFile = Path.Combine(baseFolder, config.InputFile);
Expand Down Expand Up @@ -75,7 +75,7 @@ public CompilerResult Compile(Config config)
return result;
}

private void RunCompilerProcess(Config config, FileInfo info)
private void RunCompilerProcess(ConfigEntry config, FileInfo info)
{
string arguments = ConstructArguments(config);

Expand Down Expand Up @@ -106,7 +106,7 @@ private void RunCompilerProcess(Config config, FileInfo info)
}
}

private static string ConstructArguments(Config config)
private static string ConstructArguments(ConfigEntry config)
{
string arguments = " --no-color --js";

Expand Down
2 changes: 1 addition & 1 deletion src/WebCompiler/Compile/LessOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public LessOptions()
/// <summary>
/// Load the settings from the config object
/// </summary>
protected override void LoadSettings(Config config)
protected override void LoadSettings(ConfigEntry config)
{
base.LoadSettings(config);

Expand Down
6 changes: 3 additions & 3 deletions src/WebCompiler/Compile/SassCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public SassCompiler(string path)
_path = path;
}

public CompilerResult Compile(Config config)
public CompilerResult Compile(ConfigEntry config)
{
string baseFolder = Path.GetDirectoryName(config.FileName);
string inputFile = Path.Combine(baseFolder, config.InputFile);
Expand Down Expand Up @@ -78,7 +78,7 @@ public CompilerResult Compile(Config config)
return result;
}

private void RunCompilerProcess(Config config, FileInfo info)
private void RunCompilerProcess(ConfigEntry config, FileInfo info)
{
string arguments = ConstructArguments(config);

Expand Down Expand Up @@ -127,7 +127,7 @@ private void RunCompilerProcess(Config config, FileInfo info)
}
}

private static string ConstructArguments(Config config)
private static string ConstructArguments(ConfigEntry config)
{
var arguments = new StringBuilder();

Expand Down
2 changes: 1 addition & 1 deletion src/WebCompiler/Compile/SassOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public SassOptions()
/// <summary>
/// Loads the settings based on the config
/// </summary>
protected override void LoadSettings(Config config)
protected override void LoadSettings(ConfigEntry config)
{
base.LoadSettings(config);

Expand Down
6 changes: 3 additions & 3 deletions src/WebCompiler/Compile/StylusCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public StylusCompiler(string path)
_path = path;
}

public CompilerResult Compile(Config config)
public CompilerResult Compile(ConfigEntry config)
{
string baseFolder = Path.GetDirectoryName(config.FileName);
string inputFile = Path.Combine(baseFolder, config.InputFile);
Expand Down Expand Up @@ -76,7 +76,7 @@ public CompilerResult Compile(Config config)
return result;
}

private void RunCompilerProcess(Config config, FileInfo info)
private void RunCompilerProcess(ConfigEntry config, FileInfo info)
{
string arguments = ConstructArguments(config);

Expand Down Expand Up @@ -107,7 +107,7 @@ private void RunCompilerProcess(Config config, FileInfo info)
}
}

private static string ConstructArguments(Config config)
private static string ConstructArguments(ConfigEntry config)
{
string arguments = " --print";

Expand Down
2 changes: 1 addition & 1 deletion src/WebCompiler/Compile/StylusOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public StylusOptions()
/// <summary>
/// Load the settings from the config object
/// </summary>
protected override void LoadSettings(Config config)
protected override void LoadSettings(ConfigEntry config)
{
base.LoadSettings(config);
}
Expand Down
4 changes: 2 additions & 2 deletions src/WebCompiler/Config/CompileFileEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class CompileFileEventArgs : EventArgs
/// <param name="config">The configuration object being processed.</param>
/// <param name="baseFolder">The base folder of the config file.</param>
/// <param name="containsChanges">True if there were any changes.</param>
public CompileFileEventArgs(Config config, string baseFolder, bool containsChanges)
public CompileFileEventArgs(ConfigEntry config, string baseFolder, bool containsChanges)
{
ContainsChanges = containsChanges;
Config = config;
Expand All @@ -28,7 +28,7 @@ public CompileFileEventArgs(Config config, string baseFolder, bool containsChang
/// <summary>
/// The Config object used by the compiler.
/// </summary>
public Config Config { get; set; }
public ConfigEntry Config { get; set; }

/// <summary>
/// The base folder of the current execution.
Expand Down
Loading