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