summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 907ebbdfedd85bc810b05878e4934d4739f8c7be (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
# Maintainer: Chocobo1 <chocobo1 AT archlinux DOT net>

pkgname=js-beautify-git
pkgver=1.10.2.r3.g45b073d9
pkgrel=1
pkgdesc="Beautifier for javascript"
arch=('any')
url="https://beautifier.io/"
license=('MIT')
depends=('nodejs')
makedepends=('git' 'npm')
provides=('js-beautify')
conflicts=('js-beautify')
source=("git+https://github.com/beautify-web/js-beautify.git")
sha256sums=('SKIP')


pkgver() {
  cd "js-beautify"

  _tag=$(git tag -l --sort -v:refname | sed -n '1,1{s/v//p}')
  _rev=$(git rev-list --count v$_tag..HEAD)
  _hash=$(git rev-parse --short HEAD)
  printf "%s.r%s.g%s" "$_tag" "$_rev" "$_hash" | sed 's/-/_/g'
}

build() {
  cd "js-beautify"

  npm install -D
  tools/build.sh js
}

package() {
  cd "js-beautify"

  npm install -g --user root --prefix="$pkgdir/usr" git+file://$(pwd)
  rm -r "$pkgdir/usr/lib/node_modules/js-beautify/js"/*
  cp -r js/* "$pkgdir/usr/lib/node_modules/js-beautify/js"
  install -Dm644 "LICENSE" "$pkgdir/usr/share/licenses/js-beautify/LICENSE"

  find "$pkgdir/usr" -type d -exec chmod 755 {} +
  chown -R root:root "$pkgdir"
}