diff --git a/src/Juniper.TSBuild.Core/BuildSystemOptions.cs b/src/Juniper.TSBuild.Core/BuildSystemOptions.cs index 36117dcc1..58266b263 100644 --- a/src/Juniper.TSBuild.Core/BuildSystemOptions.cs +++ b/src/Juniper.TSBuild.Core/BuildSystemOptions.cs @@ -7,6 +7,8 @@ public interface IBuildConfig public class BuildSystemOptions { + public required DirectoryInfo WorkingDir; + /// /// USE WITH CAUTION! /// A list of directories that will have their contents diff --git a/src/Juniper.TSBuild/BuildSystem.cs b/src/Juniper.TSBuild/BuildSystem.cs index e68d185b3..4fb14bc10 100644 --- a/src/Juniper.TSBuild/BuildSystem.cs +++ b/src/Juniper.TSBuild/BuildSystem.cs @@ -32,7 +32,6 @@ static void WriteWarning(string format, params object[] values) => private readonly List copyCommands = new(); private readonly bool skipPreBuild; - private readonly bool isInProjectProcess; private readonly bool hasNPM; private readonly TaskCompletionSource starting = new(); @@ -49,15 +48,12 @@ private static DirectoryInfo TestDir(string message, DirectoryInfo? dir) return dir; } - public BuildSystem(DirectoryInfo? startDir = null) + public BuildSystem() { - isInProjectProcess = startDir is null; - startDir ??= new DirectoryInfo(Environment.CurrentDirectory); - - workingDir = TestDir($"Couldn't find project root from {startDir.FullName}", startDir); - var options = new BuildConfigT().Options; + workingDir = TestDir($"Couldn't find project root from {options.WorkingDir.FullName}", options.WorkingDir); + var inProjectDir = TestDir("You must specify at least one of InProject or OutProject in your BuildConfig.", options.Project ?? options.InProject ?? options.OutProject); var outProjectDir = TestDir("You must specify at least one of InProject or OutProject in your BuildConfig.", options.Project ?? options.OutProject ?? options.InProject); @@ -80,8 +76,8 @@ public BuildSystem(DirectoryInfo? startDir = null) if (hasNPM) { var dirs = new List{ - inProjectDir - }; + inProjectDir + }; if (options.AdditionalNPMProjects is not null) { @@ -130,14 +126,14 @@ private async Task CheckNPMProjectAsync(DirectoryInfo project) if (package.scripts is not null) { - if (isInProjectProcess && package.scripts.ContainsKey("juniper-build") - || !isInProjectProcess && !isWorkSpaceSubProject && package.scripts.ContainsKey("build")) + if (isWorkSpaceSubProject && package.scripts.ContainsKey("juniper-build") + || !isWorkSpaceSubProject && package.scripts.ContainsKey("build")) { BuildProjects.Add(pkgFile); } - if (isInProjectProcess && package.scripts.ContainsKey("juniper-watch") - || !isInProjectProcess && !isWorkSpaceSubProject && package.scripts.ContainsKey("watch")) + if (isWorkSpaceSubProject && package.scripts.ContainsKey("juniper-watch") + || !isWorkSpaceSubProject && package.scripts.ContainsKey("watch")) { WatchProjects.Add(pkgFile); }