From c58c2f53e816a0f1ceeed1ac37acbeeeedd6ea68 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 16 Mar 2022 12:02:21 +0000 Subject: [PATCH] FIX: Skip ember-cli build memory optimisation for multiple rake tasks (#16198) --- lib/tasks/assets.rake | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake index 24eac30fda3..68b5db61ac5 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake @@ -14,11 +14,15 @@ task 'assets:precompile:before' do end if EMBER_CLI && !(ENV["EMBER_CLI_COMPILE_DONE"] == "1") - # Using exec to free up Rails app memory during ember build - exec <<~SH - NODE_OPTIONS='--max-old-space-size=2048' yarn --cwd app/assets/javascripts/discourse run ember build -prod && \ - EMBER_CLI_COMPILE_DONE=1 bin/rake assets:precompile - SH + compile_command = "NODE_OPTIONS='--max-old-space-size=2048' yarn --cwd app/assets/javascripts/discourse run ember build -prod" + only_assets_precompile_remaining = (ARGV.last == "assets:precompile") + + if only_assets_precompile_remaining + # Using exec to free up Rails app memory during ember build + exec "#{compile_command} && EMBER_CLI_COMPILE_DONE=1 bin/rake assets:precompile" + else + system compile_command + end end # Ensure we ALWAYS do a clean build