UNPKG

1.42 kBapplication/x-shView Raw
1#!/usr/bin/env bash
2
3set -e
4
5if [ ! -d node_modules ]; then
6 echo "[B] Run 'npm install' first"
7 exit 1
8fi
9
10
11clean() {
12 rm -f .babelrc
13 rm -rf lib/*
14 node scripts/version.js > lib/version.json
15 node scripts/assemble_lua.js > lib/lua.json
16}
17
18makeLib10() {
19 echo '[B] Compiling Bottleneck to Node 10+...'
20 npx coffee --compile --bare --no-header src/*.coffee
21 mv src/*.js lib/
22}
23
24makeLib6() {
25 echo '[B] Compiling Bottleneck to Node 6+...'
26 ln -s .babelrc.lib .babelrc
27 npx coffee --compile --bare --no-header --transpile src/*.coffee
28 mv src/*.js lib/
29}
30
31makeES5() {
32 echo '[B] Compiling Bottleneck to ES5...'
33 ln -s .babelrc.es5 .babelrc
34 npx coffee --compile --bare --no-header src/*.coffee
35 mv src/*.js lib/
36
37 echo '[B] Assembling ES5 bundle...'
38 npx rollup -c rollup.config.es5.js
39}
40
41makeLight() {
42 makeLib10
43
44 echo '[B] Assembling light bundle...'
45 npx rollup -c rollup.config.light.js
46}
47
48makeTypings() {
49 echo '[B] Compiling and testing TS typings...'
50 npx ejs-cli bottleneck.d.ts.ejs > bottleneck.d.ts
51 npx tsc --noEmit --strict test.ts
52}
53
54if [ "$1" = 'dev' ]; then
55 clean
56 makeLib10
57elif [ "$1" = 'bench' ]; then
58 clean
59 makeLib6
60elif [ "$1" = 'es5' ]; then
61 clean
62 makeES5
63elif [ "$1" = 'light' ]; then
64 clean
65 makeLight
66elif [ "$1" = 'typings' ]; then
67 makeTypings
68else
69 clean
70 makeES5
71
72 clean
73 makeLight
74
75 clean
76 makeLib6
77 makeTypings
78fi
79
80rm -f .babelrc
81
82echo '[B] Done!'