UNPKG

1 kBPlain TextView Raw
1# write message to standard out (stdout)
2# usage: msg MESSAGE
3function msg() {
4 echo "$Pkg: $*"
5}
6
7# write message to standard error (stderr)
8# usage: err MESSAGE
9function err() {
10 msg "$*" 1>&2
11}
12
13# npm publish
14# usage: npm-publish [NPM_PUBLISH_ARGS]...
15function npm-publish () {
16
17 if [ -d "build/src" ]; then
18 if ! cp -r build/src/* .; then
19 err "packaging module failed"
20 return 1
21 fi
22 fi
23
24 # npm honors this
25 rm -f .gitignore
26
27 if ! npm publish "$@"; then
28 err "failed to publish node package"
29 cat "$(ls -t "$HOME"/.npm/_logs/*-debug.log | head -n 1)"
30 return 1
31 fi
32
33 if ! git checkout -- .gitignore; then
34 err "removed .gitignore and was unable to check out original"
35 return 1
36 fi
37
38 if [ -d "build/src" ]; then
39 local pub_file pub_base
40 for pub_file in build/src/*; do
41 pub_base=${pub_file#build/src/}
42 rm -rf "$pub_base"
43 done
44 fi
45}
46
47npm-publish "$@"
\No newline at end of file