Skip to content

Commit

Permalink
refactor: simplify installation now that it can be skipped with an en…
Browse files Browse the repository at this point in the history
…v flag
  • Loading branch information
ElMassimo committed Jul 17, 2024
1 parent efb510f commit 2b96e7d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions vite_ruby/lib/tasks/vite.rake
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ namespace :vite do
desc 'Ensure build dependencies like Vite are installed before bundling'
task :install_dependencies do
install_env_args = ENV['VITE_RUBY_SKIP_INSTALL_DEV_DEPENDENCIES'] == 'true' ? {} : { 'NODE_ENV' => 'development' }
cmd = ViteRuby.commands.legacy_npm_version? ? 'npx ci --yes' : 'npx --yes ci'
result = system(install_env_args, cmd)
# Fallback to `yarn` if `npx` is not available.
system(install_env_args, 'yarn install --frozen-lockfile') if result.nil?

install_cmd = case (pkg = ViteRuby.config.package_manager)
when "npm" then "npm ci"
else "#{pkg} install --frozen-lockfile"
end

system(install_env_args, install_cmd)
end

desc "Provide information on ViteRuby's environment"
Expand Down

0 comments on commit 2b96e7d

Please sign in to comment.