2016-10-13 13:41:53 +01:00
|
|
|
#: * `tap-new` <user>`/`<repo>:
|
|
|
|
#: Generate the template files for a new tap.
|
|
|
|
|
|
|
|
module Homebrew
|
|
|
|
module_function
|
|
|
|
|
|
|
|
def write_path(tap, filename, content)
|
|
|
|
path = tap.path/filename
|
|
|
|
tap.path.mkpath
|
|
|
|
raise "#{path} already exists" if path.exist?
|
|
|
|
path.write content
|
|
|
|
end
|
|
|
|
|
|
|
|
def tap_new
|
|
|
|
raise "A tap argument is required" if ARGV.named.empty?
|
|
|
|
|
|
|
|
tap = Tap.fetch(ARGV.named.first)
|
|
|
|
titleized_user = tap.user.dup
|
|
|
|
titleized_repo = tap.repo.dup
|
|
|
|
titleized_user[0] = titleized_user[0].upcase
|
|
|
|
titleized_repo[0] = titleized_repo[0].upcase
|
|
|
|
|
|
|
|
(tap.path/"Formula").mkpath
|
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
readme = <<~EOS
|
2016-10-13 13:41:53 +01:00
|
|
|
# #{titleized_user} #{titleized_repo}
|
|
|
|
|
|
|
|
## How do I install these formulae?
|
|
|
|
`brew install #{tap}/<formula>`
|
|
|
|
|
|
|
|
Or `brew tap #{tap}` and then `brew install <formula>`.
|
|
|
|
|
|
|
|
Or install via URL (which will not receive updates):
|
|
|
|
|
|
|
|
```
|
|
|
|
brew install https://raw.githubusercontent.com/#{tap.user}/homebrew-#{tap.repo}/master/Formula/<formula>.rb
|
|
|
|
```
|
|
|
|
|
|
|
|
## Documentation
|
2017-07-27 15:59:37 +01:00
|
|
|
`brew help`, `man brew` or check [Homebrew's documentation](https://docs.brew.sh).
|
2016-10-13 13:41:53 +01:00
|
|
|
EOS
|
|
|
|
write_path(tap, "README.md", readme)
|
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
travis = <<~EOS
|
2018-01-26 16:58:23 +00:00
|
|
|
language: c
|
2016-11-26 16:30:43 +00:00
|
|
|
os: osx
|
2018-01-26 16:58:23 +00:00
|
|
|
compiler: clang
|
|
|
|
osx_image: xcode9.2
|
2017-05-08 08:38:25 +01:00
|
|
|
cache:
|
|
|
|
directories:
|
2018-02-27 14:29:55 +00:00
|
|
|
- /usr/local/Homebrew/Library/Homebrew/vendor/bundle
|
2018-01-26 16:58:23 +00:00
|
|
|
branches:
|
|
|
|
only:
|
|
|
|
- master
|
2016-11-26 16:30:43 +00:00
|
|
|
|
|
|
|
before_install:
|
2018-01-26 16:58:23 +00:00
|
|
|
- sudo chown -R "$USER" "$(brew --repo)"
|
|
|
|
- travis_retry brew update
|
2016-12-03 13:47:52 +00:00
|
|
|
- HOMEBREW_TAP_DIR="$(brew --repo "$TRAVIS_REPO_SLUG")"
|
2017-03-22 21:23:00 +00:00
|
|
|
- mkdir -p "$HOMEBREW_TAP_DIR"
|
2016-12-03 13:47:52 +00:00
|
|
|
- rm -rf "$HOMEBREW_TAP_DIR"
|
|
|
|
- ln -s "$PWD" "$HOMEBREW_TAP_DIR"
|
2016-11-26 16:30:43 +00:00
|
|
|
|
|
|
|
script:
|
|
|
|
- brew test-bot
|
2016-10-13 13:41:53 +01:00
|
|
|
EOS
|
|
|
|
write_path(tap, ".travis.yml", travis)
|
|
|
|
end
|
|
|
|
end
|