Skip to content

Commit

Permalink
Merge pull request #8162 from abpframework/bundle-command-improvement
Browse files Browse the repository at this point in the history
Use default values for bundle command if there is no config specified.
  • Loading branch information
hikalkan committed Mar 23, 2021
2 parents 0bd4d5a + 9baf15e commit 8163cb9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace Volo.Abp.Cli.Bundling
{
public class BundleConfig
{
public BundlingMode Mode { get; set; }
public string Name { get; set; }
public BundleParameterDictionary Parameters { get; set; }
public BundlingMode Mode { get; set; } = BundlingMode.BundleAndMinify;
public string Name { get; set; } = "global";
public BundleParameterDictionary Parameters { get; set; } = new();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,7 @@ public async Task BundleAsync(string directory, bool forceBuild)
var projectFilePath = projectFiles[0];

var config = ConfigReader.Read(PathHelper.GetWwwRootPath(directory));
var bundleConfig = config?.Bundle;

if (bundleConfig == null)
{
throw new BundlingException("Bundle section is missing in the appsettings.json configuration file.");
}
var bundleConfig = config.Bundle;

if (forceBuild)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ namespace Volo.Abp.Cli.Configuration
{
public class AbpCliConfig
{
public BundleConfig Bundle { get; set; }
public BundleConfig Bundle { get; set; } = new();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,24 @@ public AbpCliConfig Read(string directory)

using (var document = JsonDocument.Parse(settingsFileContent,documentOptions))
{
var element = document.RootElement.GetProperty("AbpCli");
var configText = element.GetRawText();
var options = new JsonSerializerOptions
if (document.RootElement.TryGetProperty("AbpCli", out var element))
{
Converters =
var configJson = element.GetRawText();
var options = new JsonSerializerOptions
{
new JsonStringEnumConverter()
},
ReadCommentHandling = JsonCommentHandling.Skip
};
Converters =
{
new JsonStringEnumConverter()
},
ReadCommentHandling = JsonCommentHandling.Skip
};

return JsonSerializer.Deserialize<AbpCliConfig>(configText, options);
return JsonSerializer.Deserialize<AbpCliConfig>(configJson, options);
}
else
{
return new AbpCliConfig();
}
}
}
}
Expand Down

0 comments on commit 8163cb9

Please sign in to comment.