Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check yarn version and run correct install command for yarn 2 #40722

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions railties/CHANGELOG.md
@@ -1,3 +1,7 @@
* Use correct install flags with Yarn 2.

*Markus Doits*

* Removed manifest.js and application.css in app/assets
folder when --skip-sprockets option passed as flag to rails.

Expand Down
10 changes: 9 additions & 1 deletion railties/lib/rails/tasks/yarn.rake
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