Skip to content

Instantly share code, notes, and snippets.

@takahashim
Forked from hyuki0000/makeapp.rb
Last active May 30, 2017 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takahashim/8a9a95d8fe7ade9ac1b5a440b96a5aab to your computer and use it in GitHub Desktop.
Save takahashim/8a9a95d8fe7ade9ac1b5a440b96a5aab to your computer and use it in GitHub Desktop.
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