Make rake install better

This commit is contained in:
Corey Johnson 2012-09-21 15:03:59 -07:00
parent 646d9778e5
commit 24bb300831

View File

@ -9,12 +9,10 @@ task "create-project" do
`python tools/gyp/gyp --depth=. atom.gyp`
end
task :bootstrap do
`script/bootstrap`
end
desc "Build Atom via `xcodebuild`"
task :build => ["create-project", "bootstrap"] do
task :build => "create-project" do
`script/bootstrap`
command = "xcodebuild -target Atom configuration=Release SYMROOT=#{BUILD_DIR}"
output = `#{command}`
if $?.exitstatus != 0
@ -23,6 +21,47 @@ task :build => ["create-project", "bootstrap"] do
end
end
desc "Creates symlink from `application_path() to /Applications/Atom and creates `atom` cli app"
task :install do #=> :build do
if path = application_path()
dest = File.join("/Applications", File.basename(path))
`rm -rf #{dest}`
`cp -r #{path} #{File.expand_path(dest)}`
default_usr_bin = "/opt/github/bin"
print "Where do you want the cli binary insalled (#{default_usr_bin}): "
usr_bin = $stdin.gets.strip
usr_bin = default_usr_bin if usr_bin.empty?
if Dir.exists?(usr_bin)
cli_path = "#{usr_bin}/atom"
`echo '#!/bin/sh\nopen #{dest} -n --args --resource-path="#{ATOM_SRC}" --executed-from="$(pwd)" $@' > #{cli_path} && chmod 755 #{cli_path}`
else
$stderr.puts "ERROR: Failed to install atom cli tool at '#{usr_bin}'"
exit 1
end
dot_atom_path = "#{ENV['HOME']}/.atom"
atom_template_path = "#{File.dirname(__FILE__)}/.atom"
dot_atom_exists = File.exists?(dot_atom_path) && !(File.symlink?(dot_atom_path) and File.readlink(dot_atom_path) == atom_template_path)
replace_dot_atom = true
puts dot_atom_exists
if dot_atom_exists
print "Can I replace '#{dot_atom_path}' with the default .atom directory? "
replace_dot_atom = false if STDIN.gets.strip =~ /$y/i
end
if replace_dot_atom
`rm -rf "#{dot_atom_path}"`
`ln -sf "#{atom_template_path}" "#{dot_atom_path}"`
end
puts "\033[32mType `atom` to start Atom! In Atom press `cmd-,` to edit your `.atom` directory\033[0m"
else
exit 1
end
end
desc "Clean build Atom via `xcodebuild`"
task :clean do
output = `xcodebuild clean`
@ -50,29 +89,6 @@ task :benchmark do
Rake::Task["run"].invoke("--benchmark")
end
desc "Creates symlink from `application_path() to /Applications/Atom and creates a CLI at /usr/local/bin/atom"
task :install => :build do
if path = application_path()
dest = File.join("/Applications", File.basename(path))
rm_rf dest
cp_r path, File.expand_path(dest)
usr_bin = "/opt/github/bin"
if Dir.exists?(usr_bin)
cli_path = "#{usr_bin}/atom"
`echo '#!/bin/sh\nopen #{dest} -n --args --resource-path="#{ATOM_SRC}" --executed-from="$(pwd)" $@' > #{cli_path} && chmod 755 #{cli_path}`
else
stderr.puts "ERROR: `The Setup` is required to run the atom cli tool"
end
rm_rf "#{ENV['HOME']}/.atom"
ln_sf "#{File.dirname(__FILE__)}/.atom", "#{ENV['HOME']}/.atom"
else
exit 1
end
end
desc "Remove any 'fit' or 'fdescribe' focus directives from the specs"
task :nof do
system %{find . -name *spec.coffee | xargs sed -E -i "" "s/f+(it|describe) +(['\\"])/\\1 \\2/g"}
end