1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #40950 from jonathanhefner/bin-yarn-find-yarn-exe

Search for yarn.exe in bin/yarn
This commit is contained in:
Eugene Kenny 2020-12-27 23:04:36 +00:00 committed by GitHub
commit 757970eefb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,15 +1,13 @@
require 'pathname'
APP_ROOT = File.expand_path('..', __dir__)
Dir.chdir(APP_ROOT) do
executable_path = ENV["PATH"].split(File::PATH_SEPARATOR).find do |path|
normalized_path = File.expand_path(path)
yarn = ENV["PATH"].split(File::PATH_SEPARATOR).
select { |dir| File.expand_path(dir) != __dir__ }.
product(["yarn", "yarn.exe"]).
map { |dir, file| File.expand_path(file, dir) }.
find { |file| File.executable?(file) }
normalized_path != __dir__ && File.executable?(Pathname.new(normalized_path).join('yarn'))
end
if executable_path
exec File.expand_path(Pathname.new(executable_path).join('yarn')), *ARGV
if yarn
exec yarn, *ARGV
else
$stderr.puts "Yarn executable was not detected in the system."
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"