]> git.openstreetmap.org Git - rails.git/blobdiff - bin/yarn
Merge remote-tracking branch 'upstream/pull/3227'
[rails.git] / bin / yarn
index 38f278aa087e2bbab837f887c2ff66b90b40d8be..be76eec945cb9b8611a0a4e9885775a5421bac29 100755 (executable)
--- a/bin/yarn
+++ b/bin/yarn
@@ -1,9 +1,15 @@
 #!/usr/bin/env ruby
 APP_ROOT = File.expand_path("..", __dir__)
 Dir.chdir(APP_ROOT) do
 #!/usr/bin/env ruby
 APP_ROOT = File.expand_path("..", __dir__)
 Dir.chdir(APP_ROOT) do
-  begin
-    exec "yarnpkg", *ARGV
-  rescue Errno::ENOENT
+  yarn = ENV["PATH"].split(File::PATH_SEPARATOR)
+                    .reject { |dir| File.expand_path(dir) == __dir__ }
+                    .product(["yarnpkg", "yarn", "yarn.cmd", "yarn.ps1"])
+                    .map { |dir, file| File.expand_path(file, dir) }
+                    .find { |file| File.executable?(file) }
+
+  if yarn
+    exec yarn, *ARGV
+  else
     warn "Yarn executable was not detected in the system."
     warn "Download Yarn at https://yarnpkg.com/en/docs/install"
     exit 1
     warn "Yarn executable was not detected in the system."
     warn "Download Yarn at https://yarnpkg.com/en/docs/install"
     exit 1