Skip to content

Instantly share code, notes, and snippets.

@hyuki
Forked from hyuki0000/makeapp.rb
Created Jan 31, 2019
Embed
What would you like to do?
makeapp - スクリプトをMacのアプリケーションにする
#!/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