summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 9228ef488d5004dc09a3b9a9c037a1d588a7bfd8 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Maintainer: Daniel M. Capella <polyzen@archlinux.org>

pkgname=typescript-language-server-git
pkgver=0.6.0.r0.ge57e49f
pkgrel=1
pkgdesc='Language Server Protocol (LSP) implementation for TypeScript using tsserver'
url=https://github.com/theia-ide/typescript-language-server
arch=('any')
license=('Apache')
depends=('typescript')
makedepends=('git' 'jq' 'yarn')
checkdepends=('npm')
provides=("${pkgname%-git}")
conflicts=("${pkgname%-git}")
source=("git+$url.git")
b2sums=('SKIP')

pkgver() {
  cd ${pkgname%-git}
  git describe --long | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
  cd ${pkgname%-git}
  yarn --frozen-lockfile
}

build() {
  cd ${pkgname%-git}
  yarn compile # Needs bin links
}

check() {
  cd ${pkgname%-git}
  yarn test
}

package() {
  cd ${pkgname%-git}

  # Emulate `npm prune --production`
  cp package.json{,.bak}
  read -ra devDependencies < <(jq -r '.devDependencies | keys | join(" ")' package.json)
  yarn remove --frozen-lockfile "${devDependencies[@]}"
  mv package.json{.bak,}

  install -d "$pkgdir"/usr/{bin,lib/node_modules/${pkgname%-git}}
  ln -s ../lib/node_modules/${pkgname%-git}/lib/cli.js \
    "$pkgdir"/usr/bin/${pkgname%-git}
  chmod +x lib/cli.js
  cp -r lib node_modules package.json \
    "$pkgdir"/usr/lib/node_modules/${pkgname%-git}
  install -Dm644 -t "$pkgdir"/usr/share/doc/$pkgname {CHANGELOG,README}.md
}

# vim:set ts=2 sw=2 et: