-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathBundler.cs
More file actions
68 lines (56 loc) · 1.78 KB
/
Bundler.cs
File metadata and controls
68 lines (56 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/
namespace BootstrapBlazor.CssBundler;
internal class Bundler
{
public static void Run(string[] args)
{
#if DEBUG
if (args.Length == 0)
{
args = [
"C:\\Users\\Argo\\src\\BootstrapBlazor\\src\\BootstrapBlazor\\bundler.json"
];
}
#endif
var bundlerFile = ArgumentsHelper.ParseOptions(args);
if (string.IsNullOrEmpty(bundlerFile))
{
ArgumentsHelper.PrintHelp();
return;
}
BundlerCore(bundlerFile);
}
static void BundlerCore(string bundlerFile)
{
var option = BundlerOptions.LoadFromConfigFile(bundlerFile);
if (string.IsNullOrEmpty(option.OutputFileName))
{
return;
}
if (option.InputFiles.Count == 0)
{
return;
}
var rootFolder = Path.GetDirectoryName(bundlerFile);
if (string.IsNullOrEmpty(rootFolder))
{
return;
}
using var writer = File.OpenWrite(Path.Combine(rootFolder, option.OutputFileName));
foreach (var file in option.InputFiles)
{
var inputFile = Path.Combine(rootFolder, file);
if (!File.Exists(inputFile))
{
continue;
}
using var reader = File.OpenText(inputFile);
reader.BaseStream.CopyTo(writer);
reader.Close();
}
writer.Close();
Console.WriteLine($"Bundler Completed .... {option.OutputFileName}");
}
}