aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/npm.rb
blob: f612b291bfef01aa56c068f56dd04dd4320c2f0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require 'formula'

class Npm <Formula
  url 'http://github.com/isaacs/npm/tarball/v0.1.20'
  homepage 'http://github.com/isaacs/npm'
  md5 '9ad6a2892ea673c03c9df528c4ac25d6'
  head 'git://github.com/isaacs/npm.git'

  depends_on 'node'

  def executable
    <<-EOS
#!/bin/sh
exec "#{libexec}/cli.js" "$@"
    EOS
  end

  def install
    doc.install Dir["doc/*"]
    prefix.install ["LICENSE", "README.md"]

    # install all the required libs in libexec so `npm help` will work
    libexec.install Dir["*"]

    # add "npm-" prefix to man pages link them into the libexec man pages
    man1.mkpath
    Dir.chdir libexec+"man" do
      Dir["*"].each do |file|
        if file == "npm.1"
          ln_s "#{libexec}/man/#{file}", man1
        else
          ln_s "#{libexec}/man/#{file}", "#{man1}/npm-#{file}"
        end
      end
    end

    # install the wrapper executable
    (bin+"npm").write executable
  end
end