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

Merge pull request #40785 from Stellenticket/yarn_command_with_spaces

Allow spaces in path to Yarn binstub and only run on precompile if needed
This commit is contained in:
Rafael França 2020-12-16 19:07:38 -05:00 committed by GitHub
commit 002e802ce0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,17 +10,21 @@ namespace :yarn do
end
yarn_flags =
if `#{Rails.root}/bin/yarn --version`.start_with?("1")
if `"#{Rails.root}/bin/yarn" --version`.start_with?("1")
"--no-progress --frozen-lockfile"
else
"--immutable"
end
system({ "NODE_ENV" => node_env }, "#{Rails.root}/bin/yarn install #{yarn_flags}")
system({ "NODE_ENV" => node_env }, "\"#{Rails.root}/bin/yarn\" install #{yarn_flags}")
rescue Errno::ENOENT
$stderr.puts "bin/yarn was not found."
$stderr.puts "Please run `bundle exec rails app:update:bin` to create it."
exit 1
end
end
# Run Yarn prior to Sprockets assets precompilation, so dependencies are available for use.
if Rake::Task.task_defined?("assets:precompile")
if Rake::Task.task_defined?("assets:precompile") && File.exist?(Rails.root.join("bin", "yarn"))
Rake::Task["assets:precompile"].enhance [ "yarn:install" ]
end