A platform for community discussion. Free, open, simple.
DEV: Fix bin/lint and bin/qunit directory path handling (#38569)
Sérgio Saquetim614600d7b573
diff --git a/bin/lint b/bin/lintindex 58790e8e3c9..b3d3bc0d77d 100755--- a/bin/lint+++ b/bin/lint@@ -49,7 +49,17 @@ class LefthookLinterendfiles- .map { |f| normalize_relative_path(f) }+ .flat_map { |f|+ path = normalize_relative_path(f)+ if File.directory?(path)+ expanded = Dir.glob(File.join(path, "**", "*"))+ .select { |g| File.file?(g) && lintable_file?(g) }+ abort "Error: No lintable files found in directory: #{path}" if expanded.empty?+ expanded+ else+ [path]+ end+ }.select { |f| File.file?(f) && lintable_file?(f) }.uniqend@@ -222,7 +232,7 @@ def parse_optionsOptionParser.new do |parser|- parser.banner = "Usage: bin/lint [options] [files...]"+ parser.banner = "Usage: bin/lint [options] [files|directories...]"parser.on("-h", "--help", "Show this help message") doputs parser@@ -235,6 +245,7 @@ def parse_optionsputs " bin/lint --wip # Lint staged + unstaged + files changed since main"puts " bin/lint --fix app.rb file2.js # Fix specific file/s"puts " bin/lint app/models/*.rb # Lint multiple files"+ puts " bin/lint frontend/discourse/app/ # Lint all lintable files in directory"putsputs "Note: This script now uses lefthook to run linters."puts "Check lefthook.yml for linting configuration."diff --git a/bin/qunit b/bin/qunitindex 6a19f9e6397..e3143deb515 100755--- a/bin/qunit+++ b/bin/qunit@@ -122,6 +122,7 @@ class QunitRunneropts.separator <<~NOTES\nExamples:bin/qunit frontend/discourse/tests/unit/models/user-test.js+ bin/qunit frontend/discourse/tests/unit/ # Run all tests in directorybin/qunit --standalone --target plugins # Run all plugin testsbin/qunit --standalone --target chat # Run single plugin testsbin/qunit --standalone plugins/chat/test/javascripts/unit/lib/chat-audio-test.js@@ -183,7 +184,7 @@ class QunitRunnerif File.directory?(path)test_files = Dir.glob(File.join(path, "**", "*-test.{js,gjs}"))if test_files.empty?- puts "Warning: No test files found in directory: #{path}" if @verbose+ abort "Error: No test files found in directory: #{path}"elseexpanded.concat(test_files)end