From 03d2001cf2ee0bc93d5e413b30387382ec13e1e9 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Mon, 18 Jul 2022 01:32:44 +0200 Subject: [PATCH] Update yarn files for rails 6 Also allow `yarnpkg` binary for `bin/yarn` --- bin/setup | 3 +++ bin/yarn | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/bin/setup b/bin/setup index 57923026c..90700ac4f 100755 --- a/bin/setup +++ b/bin/setup @@ -17,6 +17,9 @@ FileUtils.chdir APP_ROOT do system! 'gem install bundler --conservative' system('bundle check') || system!('bundle install') + # Install JavaScript dependencies + system! 'bin/yarn' + # puts "\n== Copying sample files ==" # unless File.exist?('config/database.yml') # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' diff --git a/bin/yarn b/bin/yarn index 460dd565b..da9264ff5 100755 --- 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 - begin - exec "yarnpkg", *ARGV - rescue Errno::ENOENT + yarn = ENV["PATH"].split(File::PATH_SEPARATOR). + select { |dir| File.expand_path(dir) != __dir__ }. + product(["yarn", "yarn.cmd", "yarn.ps1", "yarnpkg"]). + map { |dir, file| File.expand_path(file, dir) }. + find { |file| File.executable?(file) } + + 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" exit 1