-
-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathpublish.sh
More file actions
executable file
·28 lines (24 loc) · 635 Bytes
/
publish.sh
File metadata and controls
executable file
·28 lines (24 loc) · 635 Bytes
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
#!/usr/bin/env bash
# $1 is an npm token
# Exit when any command fail
set -eo pipefail
# Get package name from package.json
PACKAGE_NAME=$(cat package.json \
| grep name \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g' \
| tr -d '[[:space:]]')
# Get package version from package.json
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g' \
| tr -d '[[:space:]]')
if npm show "$PACKAGE_NAME" version | grep -w "$PACKAGE_VERSION" > /dev/null; then
echo "Already published!";
else
npm set //registry.npmjs.org/:_authToken=$1
npm publish;
fi