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:
commit
002e802ce0
1 changed files with 7 additions and 3 deletions
|
@ -10,17 +10,21 @@ namespace :yarn do
|
||||||
end
|
end
|
||||||
|
|
||||||
yarn_flags =
|
yarn_flags =
|
||||||
if `#{Rails.root}/bin/yarn --version`.start_with?("1")
|
if `"#{Rails.root}/bin/yarn" --version`.start_with?("1")
|
||||||
"--no-progress --frozen-lockfile"
|
"--no-progress --frozen-lockfile"
|
||||||
else
|
else
|
||||||
"--immutable"
|
"--immutable"
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
# Run Yarn prior to Sprockets assets precompilation, so dependencies are available for use.
|
# 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" ]
|
Rake::Task["assets:precompile"].enhance [ "yarn:install" ]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue