check yarn version and run correct install command

This commit is contained in:
Markus Doits 2020-12-01 21:43:35 +01:00 committed by Rafael Mendonça França
parent 45d1efab51
commit bd4d8fdfce
No known key found for this signature in database
GPG Key ID: FC23B6D0F1EEE948

@ -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