summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 4a2b6484e149c6b1b415e9f332abc638eea2533e (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
57
58
59
60
# Maintainer: Chih-Hsuan Yen <yan12125@gmail.com>

_npmname=web-ext
pkgname=nodejs-$_npmname
pkgver=3.2.0
pkgrel=2
pkgdesc='A command line tool to help build, run, and test web extensions'
arch=(any)
url='https://developer.mozilla.org/en-US/Add-ons/WebExtensions'
license=('MPL2')
depends=('nodejs')
makedepends=('yarn' 'node-gyp' 'python2' 'git')
# to speed up the build
options=('!strip')
# unit tests expect a git repo
source=("git+https://github.com/mozilla/web-ext.git#tag=$pkgver")
sha256sums=('SKIP')

prepare() {
  cd "$srcdir"
  # -build for running webpack and tests, and the original for actual packaging
  cp -r $_npmname{,-build}

  # Chromium tests are flaky
  rm -v $_npmname-build/tests/unit/test-extension-runners/test.chromium.js
}

build() {
  cd "$srcdir/$_npmname-build"

  PYTHON=python2 yarn install
  NODE_ENV=production yarn run build
  cp -r dist "$srcdir/$_npmname"

  cd "$srcdir/$_npmname"
  PYTHON=python2 yarn install --production
}

check() {
  cd "$srcdir/$_npmname-build"

  yarn test
}

package() {
  local _npmdir="$pkgdir/usr/lib/node_modules/"

  install -Ddm755 "$_npmdir"
  cp -r --no-preserve=ownership $_npmname "$_npmdir/$_npmname"

  # remove references to $pkgdir
  rm -r "$_npmdir"/web-ext/node_modules/dtrace-provider/build/

  rm -r "$_npmdir"/web-ext/.git

  install -Ddm755 "$pkgdir/usr/bin"
  ln -s "/usr/lib/node_modules/$_npmname/bin/$_npmname" "$pkgdir/usr/bin/$_npmname"
}

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