Created
July 21, 2023 15:14
-
-
Save eknowles/6b9b0b9899846d4345936d7923938f7f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
write_npm_token() { | |
local username=$1 | |
local password=$2 | |
local rc="${HOME}/.zshrc" | |
# Use sed to remove lines starting with "export NPM_TOKEN=" | |
sed -i '/^export NPM_TOKEN=/d' "$rc" | |
new_token=$(echo -n "${username}:${password}" | openssl base64 -A) | |
# write token to rc file | |
echo "export NPM_TOKEN=$new_token" >> "$rc" | |
# tell user it's done | |
echo "New NPM_TOKEN has been updated in $rc" | |
} | |
read -pr "Enter your email (artifactory username):" email | |
read -spr "Paste your artifactory reference token (press Enter when done):" reftoken | |
write_npm_token "$email" "$reftoken" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment