Skip to content

Instantly share code, notes, and snippets.

@takahashim
Forked from hyuki0000/makeapp.rb
Last active May 30, 2017
Embed
What would you like to do?
makeapp - スクリプトをMacのアプリケーションにする
#!/usr/bin/env ruby
# cf. http://bit.ly/2raKfLZ
# makeapp - スクリプトをMacのアプリケーションにする
require 'fileutils'
if ARGV.length != 2
abort("Usage: makeapp foo.rb Foo.app")
end
scriptname = ARGV[0]
appname = ARGV[1]
FileUtils.mkdir_p "#{appname}/Contents/MacOS"
FileUtils.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
FileUtils.cp scriptname, "#{appname}/Contents/MacOS/"
FileUtils.chmod "+x", "#{appname}/Contents/MacOS/#{scriptname}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment