Sha256: fe091daf5338f3c24e4155a3e4c200662549cdb7013aa22394129d73ceb3995a
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true module Inertia module Generators class JSPackageManager def self.package_managers %w[npm yarn bun pnpm] end def initialize(generator) @generator = generator end def present? package_manager.present? end def add_dependencies(*dependencies) options = @generator.options[:verbose] ? '' : ' --silent' @generator.in_root do @generator.run "#{package_manager} add #{dependencies.join(' ')}#{options}" end end private def package_manager @package_manager ||= @generator.options[:package_manager] || detect_package_manager end def detect_package_manager return nil unless file?('package.json') if file?('package-lock.json') 'npm' elsif file?('bun.lockb') 'bun' elsif file?('pnpm-lock.yaml') 'pnpm' else 'yarn' end end def file?(*relative_path) @generator.file?(*relative_path) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
inertia_rails-3.5.0 | lib/generators/inertia/install/js_package_manager.rb |