From 1d4bb7be5acf0a67bf94a504daaa682decc8c09c Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 11 Sep 2026 16:41:44 +0000 Subject: [PATCH] Pass --watcher only when the build watches `Command#ember_build` puts `--watcher` on the command line whenever a watcher is configured, whether or not the build watches. The flag names the backend `ember build` watches the file system with, so it has no effect on a build that does not watch: `rake ember:compile` and `assets:precompile` of an application configured with `watcher`, through the app option or `EmberCli.configuration`, carried it for nothing. Gate the flag on `watch`, and say in the classic builder's comment why it only rides along with `--watch`. A watching build is unchanged, and the existing examples for it already pass `watch: true`. Co-Authored-By: Claude Opus 5 --- CHANGELOG.md | 3 +++ lib/ember_cli/command.rb | 5 ++++- spec/lib/ember_cli/command_spec.rb | 9 +++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2782670c..a910c21c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ main ------ +* Pass `--watcher` to `ember build` only when the build watches. The flag + names the backend that watches the file system, so it did nothing for a + one-off build * Build a Vite-based application with `vite build`, the command its own `build` script runs, rather than with `ember build`. `ember build --help` calls itself a "Vestigial command in Vite-based projects" and points at diff --git a/lib/ember_cli/command.rb b/lib/ember_cli/command.rb index b79f00fc..22dd248a 100644 --- a/lib/ember_cli/command.rb +++ b/lib/ember_cli/command.rb @@ -86,11 +86,14 @@ def vite_build # Builds the application with `ember build`, which watches for changes # when asked. A Vite-based project has no equivalent: `ember build` there # refuses `--watch`, and its development server watches instead. + # + # `--watcher` names the backend that watches, so it rides along only + # when the build watches. def ember_build(watch: false) line = Terrapin::CommandLine.new(paths.ember, [ "build", ("--watch" if watch), - ("--watcher :watcher" if process_watcher), + ("--watcher :watcher" if watch && process_watcher), ("--silent" if silent?), "--environment :environment", "--output-path :output_path", diff --git a/spec/lib/ember_cli/command_spec.rb b/spec/lib/ember_cli/command_spec.rb index 932c1f81..6b5b13a9 100644 --- a/spec/lib/ember_cli/command_spec.rb +++ b/spec/lib/ember_cli/command_spec.rb @@ -77,6 +77,15 @@ end end + context "when not configured to watch" do + it "omits the `--watcher` flag" do + paths = build_paths + command = build_command(paths: paths, options: { watcher: "foo" }) + + expect(command.build).not_to match(/--watcher/) + end + end + context "when configured to watch" do it "includes the `--watch` flag" do paths = build_paths