From e72d413a69b6082ffac6a74a20dd390eb3e0a40d Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Fri, 10 Nov 2023 13:07:34 +0100 Subject: [PATCH 1/2] added new runImpl that takes plugins Signed-off-by: Erik Jan de Wit --- pkg/cli/cli.go | 9 ++++++++- pkg/cli/cli_impl.go | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/cli/cli.go b/pkg/cli/cli.go index d8a9e1e57ee..3bde32aa45c 100644 --- a/pkg/cli/cli.go +++ b/pkg/cli/cli.go @@ -28,7 +28,14 @@ import ( // "esbuild" executable such as the lack of auxiliary flags (e.g. "--help" and // "--version") but it is otherwise exactly the same code. func Run(osArgs []string) int { - return runImpl(osArgs) + return runImpl(osArgs, []api.Plugin{}) +} + +// This function invokes the esbuild CLI. It takes an array of command-line +// arguments (excluding the executable argument itself) and returns an exit +// code. It also takes adds some plugins that need to be added to the run +func RunWithPlugins(osArgs []string, plugin []api.Plugin) int { + return runImpl(osArgs, plugin) } // This parses an array of strings into an options object suitable for passing diff --git a/pkg/cli/cli_impl.go b/pkg/cli/cli_impl.go index 8e292cc315b..2ea7b8945b1 100644 --- a/pkg/cli/cli_impl.go +++ b/pkg/cli/cli_impl.go @@ -1127,7 +1127,7 @@ func addAnalyzePlugin(buildOptions *api.BuildOptions, analyze analyzeMode, osArg buildOptions.Metafile = true } -func runImpl(osArgs []string) int { +func runImpl(osArgs []string, plugins []api.Plugin) int { // Special-case running a server for _, arg := range osArgs { if arg == "--serve" || @@ -1278,6 +1278,8 @@ func runImpl(osArgs []string) int { } } + buildOptions.Plugins = plugins + // buildOptions.Plugins = append(buildOptions.Plugins, scssPlugin) // Handle post-build actions with a plugin so they also work in watch mode buildOptions.Plugins = append(buildOptions.Plugins, api.Plugin{ Name: "PostBuildActions", From 4309b3e33d9eedef20d9423910f8185e3cc8223e Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Thu, 21 Dec 2023 13:54:38 +0100 Subject: [PATCH 2/2] Update pkg/cli/cli_impl.go Co-authored-by: Andy Damevin --- pkg/cli/cli_impl.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/cli/cli_impl.go b/pkg/cli/cli_impl.go index 2ea7b8945b1..7e45ff30fa3 100644 --- a/pkg/cli/cli_impl.go +++ b/pkg/cli/cli_impl.go @@ -1279,7 +1279,6 @@ func runImpl(osArgs []string, plugins []api.Plugin) int { } buildOptions.Plugins = plugins - // buildOptions.Plugins = append(buildOptions.Plugins, scssPlugin) // Handle post-build actions with a plugin so they also work in watch mode buildOptions.Plugins = append(buildOptions.Plugins, api.Plugin{ Name: "PostBuildActions",