Skip to content

Commit

Permalink
check yarn version and run correct install command
Browse files Browse the repository at this point in the history
  • Loading branch information
doits authored and rafaelfranca committed Dec 8, 2020
1 parent 45d1efa commit bd4d8fd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion railties/lib/rails/tasks/yarn.rake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ namespace :yarn do
node_env = ENV.fetch("NODE_ENV") do
valid_node_envs.include?(Rails.env) ? Rails.env : "production"
end
system({ "NODE_ENV" => node_env }, "#{Rails.root}/bin/yarn install --no-progress --frozen-lockfile")

yarn_flags =
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}")
end
end

Expand Down

0 comments on commit bd4d8fd

Please sign in to comment.