summaryrefslogtreecommitdiffstats
path: root/tools/make-npm.sh
blob: 6bffadc735646fa08b4a542af540a13d4ed9b5d7 (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
#!/usr/bin/env bash
#
# This script assumes a linux environment

set -e

DES="dist/build/uBlock0.npm"

TMPDIR="$PWD/tmp"
mkdir -p "$TMPDIR/node_modules"

rm -rf $DES

./tools/make-nodejs.sh $DES
./tools/make-assets.sh $DES

# Target-specific
cp    platform/npm/.npmignore  $DES/
cp    platform/npm/*.json      $DES/
cp    platform/npm/.*.json     $DES/
cp    platform/npm/*.js        $DES/
cp -R platform/npm/tests       $DES/

cd $DES
cd tests/data
tar xzf bundle.tgz
cd -
npm run build
tarballname=$(npm pack 2> /dev/null)
if [ "$1" ]; then
    echo "*** uBlock0.npm: Creating versioned package..."
    mv $tarballname ../uBlock0_$1.npm.tgz
else
    echo "*** uBlock0.npm: Creating plain package..."
    mv $tarballname ../uBlock0.npm.tgz
fi
ln -sf "$TMPDIR/node_modules"
if [ -z "$GITHUB_ACTIONS" ]; then
    npm install
fi
cd -

echo "*** uBlock0.npm: Package done."