Skip to content

Commit

Permalink
fix(config): consider the full config path when parsing config files
Browse files Browse the repository at this point in the history
Otherwise we have issues when the config file is in the same folder as the exe
  • Loading branch information
AndyTWF committed Jan 30, 2021
1 parent 3d8ebe3 commit 3cf265e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Compiler/Config/ConfigFileLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,26 @@ public ConfigInclusionRules LoadConfigFiles(List<string> files, CompilerArgument

foreach (string file in files)
{
// Get the full path to the config file
string fullPath = Path.GetFullPath(file);

// Parse the config file as JSON
JObject jsonConfig;
try
{
jsonConfig = JObject.Parse(File.ReadAllText(file));
jsonConfig = JObject.Parse(File.ReadAllText(fullPath));
}
catch (Newtonsoft.Json.JsonReaderException e)
{
throw new ConfigFileInvalidException("Invalid JSON in " + file + ": " + e.Message);
throw new ConfigFileInvalidException("Invalid JSON in " + fullPath + ": " + e.Message);
}
catch (FileNotFoundException)
{
throw new ConfigFileInvalidException("Config file not found");
}

includeLoader.LoadConfig(config, jsonConfig, file);
optionsLoader.LoadOptions(arguments, jsonConfig, file);
includeLoader.LoadConfig(config, jsonConfig, fullPath);
optionsLoader.LoadOptions(arguments, jsonConfig, fullPath);
}

return config;
Expand Down

0 comments on commit 3cf265e

Please sign in to comment.