mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-05-01 03:00:26 -04:00
39 lines
1.3 KiB
Ruby
39 lines
1.3 KiB
Ruby
require 'package'
|
|
|
|
class Composer < Package
|
|
description 'Dependency Manager for PHP'
|
|
homepage 'https://getcomposer.org/'
|
|
version '2.4.0'
|
|
license 'MIT'
|
|
compatibility 'all'
|
|
source_url 'SKIP'
|
|
|
|
depends_on 'php74' unless File.exist? "#{CREW_PREFIX}/bin/php"
|
|
depends_on 'xdg_base'
|
|
|
|
no_compile_needed
|
|
|
|
def self.preinstall
|
|
if Dir.exist?("#{HOME}/.config") && !File.symlink?("#{HOME}/.config")
|
|
# Save any existing configuration
|
|
FileUtils.cp_r "#{HOME}/.config", "#{CREW_PREFIX}", remove_destination: true unless Dir.empty? "#{HOME}/.config"
|
|
else
|
|
# Remove the symlink, if it exists
|
|
FileUtils.rm_f "#{HOME}/.config"
|
|
end
|
|
end
|
|
|
|
def self.install
|
|
downloader "https://github.com/composer/composer/releases/download/#{version}/composer.phar",
|
|
'1cdc74f74965908d0e98d00feeca37c23b86da51170a3a11a1538d89ff44d4dd', 'composer'
|
|
FileUtils.mkdir_p "#{CREW_DEST_PREFIX}/bin"
|
|
FileUtils.install 'composer', "#{CREW_DEST_PREFIX}/bin/composer", mode: 0o755
|
|
end
|
|
|
|
def self.postinstall
|
|
FileUtils.ln_sf "#{CREW_PREFIX}/.config", "#{HOME}/.config"
|
|
puts "\nTo finish the installation, execute the following:".lightblue
|
|
puts "echo 'export PATH=\$HOME/.config/composer/vendor/bin:\$PATH' >> ~/.bashrc && . ~/.bashrc\n".lightblue
|
|
end
|
|
end
|