DEV: Ignore prettier error when there are no ES6 files

DEV: Ignore prettier error when there are no ES6 files

diff --git a/lib/tasks/docker.rake b/lib/tasks/docker.rake
index 65276b7..2099dec 100644
--- a/lib/tasks/docker.rake
+++ b/lib/tasks/docker.rake
@@ -28,10 +28,10 @@
 #   Run tests for a specific plugin (with a plugin mounted from host filesystem):
 #       docker run -e SKIP_CORE=1 SINGLE_PLUGIN='my-awesome-plugin' -v $(pwd)/my-awesome-plugin:/var/www/discourse/plugins/my-awesome-plugin discourse/discourse_test:release
 
-def run_or_fail(command)
+def run_or_fail(command, allowed_exit_codes: [0])
   pid = Process.spawn(command)
   Process.wait(pid)
-  $?.exitstatus == 0
+  allowed_exit_codes.include?($?.exitstatus)
 end
 
 desc 'Run all tests (JS and code in a standalone environment)'
@@ -49,7 +49,7 @@ task 'docker:test' do
         @good &&= run_or_fail("yarn eslint --ext .es6 plugins/#{ENV['SINGLE_PLUGIN']}")
 
         puts "Listing prettier offenses in #{ENV['SINGLE_PLUGIN']}:"
-        @good &&= run_or_fail("yarn prettier --list-different 'plugins/#{ENV['SINGLE_PLUGIN']}/**/*.scss' 'plugins/#{ENV['SINGLE_PLUGIN']}/**/*.es6'")
+        @good &&= run_or_fail("yarn prettier --list-different 'plugins/#{ENV['SINGLE_PLUGIN']}/**/*.scss' 'plugins/#{ENV['SINGLE_PLUGIN']}/**/*.es6'", allowed_exit_codes: [0, 2])
       else
         @good &&= run_or_fail("bundle exec rubocop --parallel") unless ENV["SKIP_CORE"]
         @good &&= run_or_fail("yarn eslint app/assets/javascripts test/javascripts") unless ENV["SKIP_CORE"]
@@ -62,7 +62,7 @@ task 'docker:test' do
 
         unless ENV["SKIP_PLUGINS"]
           puts "Listing prettier offenses in plugins:"
-          @good &&= run_or_fail('yarn prettier --list-different "plugins/**/*.scss" "plugins/**/*.es6"')
+          @good &&= run_or_fail('yarn prettier --list-different "plugins/**/*.scss" "plugins/**/*.es6"', allowed_exit_codes: [0, 2])
         end
       end
       puts "travis_fold:end:lint" if ENV["TRAVIS"]

GitHub
sha: d06ca90c

2 Likes

DEV: Skip prettier in single plugin test if patterns aren't found