Created
May 28, 2017 04:34
-
-
Save hyuki0000/188d5aaa956b8f83a583ed9ae2f05ef4 to your computer and use it in GitHub Desktop.
makeapp - スクリプトをMacのアプリケーションにする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# cf. http://bit.ly/2raKfLZ | |
# makeapp - スクリプトをMacのアプリケーションにする | |
if ARGV.length != 2 | |
abort("Usage: makeapp foo.rb Foo.app") | |
end | |
scriptname = ARGV[0] | |
appname = ARGV[1] | |
system("mkdir -p #{appname}/Contents/MacOS") | |
system("mkdir -p #{appname}/Contents/Resources") | |
open("#{appname}/Contents/Info.plist", "w") do |f| | |
f.puts <<-"EOD" | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>CFBundleExecutable</key> | |
<string>#{scriptname}</string> | |
</dict> | |
</plist> | |
EOD | |
end | |
system("cp #{scriptname} #{appname}/Contents/MacOS/") | |
system("chmod +x #{appname}/Contents/MacOS/#{scriptname}") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
makeopenapp.rb