#!/bin/bash PATH="$PWD/node_modules/.bin":$PATH set -e build() { set -x rm -rfv dist cp -rfv src dist cat tsconfig.json | jq 'del(.include, .compilerOptions.outDir)' > dist/tsconfig.json cp -v README.md LICENSE package.json dist cd dist /usr/bin/find . -name '*.spec.ts' | xargs rm -rvf tsc -p . rm -rvf tsconfig.json cd .. set +x } bundle() { set -x rm -rfv dist cp -rfv src dist cat tsconfig.json | jq '.compilerOptions.module = "esnext" | del(.include, .compilerOptions.outDir)' > dist/tsconfig.json cp -v README.md LICENSE package.json dist cd dist /usr/bin/find . -name '*.spec.ts' | xargs rm -rvf npx microbundle -i index.ts --no-compress -f es,umd -o . rm -rvf tsconfig.json /usr/bin/find . -name '.rts2*' | xargs rm -rf package=$(cat package.json) echo "$package" | jq '.main = "bundle.umd.js"' \ | jq '.module = "bundle.mjs"' \ > package.json cd .. set +x } git_last_release_tag() { result="" rev=$(git rev-list --max-count=1 --tags="v[0-9]*\\.[0-9]*\\.[0-9]*") if [ -n "$rev" ]; then result=$(git describe --tags $rev) fi if [ -n "$result" ]; then result=$(git rev-list --max-parents=0 HEAD) fi echo $result } commit_lint() { set -x from=$(git_last_release_tag) commitlint --from $from } commit_msg() { if git-branch-is -q -r "^(master)"; then commitlint -E HUSKY_GIT_PARAMS else true fi } "$@"