Skip to content

Commit 6c2ad1e

Browse files
committed
1.0.4 :: add NX_EXTEND_ALIASES feature
1 parent 6e287cb commit 6c2ad1e

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

nx.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# :: nx 1.0.3 ::
2+
# :: nx 1.0.4 ::
33
# shellcheck disable=SC2139 # shellcheck.net/wiki/SC2139 # allow parameter expansion within alias strings #
44
function nx() ( local pkg="" cmd="" npmcmds=""
55
npmcmds="$( npm -h | awk '/access/,/whoami/' | sed -E 's/ (help|start|test),//g' | xargs | sed 's/, /|/g' )" || true
@@ -17,9 +17,11 @@ function nx() ( local pkg="" cmd="" npmcmds=""
1717
done
1818
# :: call "nvm use" automatically before running commands :: to enable auto-nvm behavior, export NX_NVM=1; source "$HOME/nx/nx.sh" ::
1919
[[ "${NX_NVM}" =~ ^(1|true|TRUE)$ ]] && nvm use &>/dev/null
20-
# :: await confirmation of current node+npm versions before executing command :: to enable await-confirm behavior, export NX_CONFIRM=1; source "$HOME/nx/nx.sh" ::
20+
# :: await confirmation of current node+npm versions before executing command :: to enable await-confirm behavior, export NX_CONFIRM=1 source "$HOME/nx/nx.sh" ::
2121
if [[ "${NX_CONFIRM}" =~ ^(1|true|TRUE)$ ]]; then
2222
read -rsn1 -p "${cmd[*]} ${*}"$'\n'"${cmd[*]//?/˙} ${*//?/˙}"$'\n'"Press any key to run · CTRL+C to cancel · node $( node -v ) · npm $( npm -v )"$'\n\n'
23+
elif ! [[ "${NX_QUIET}" =~ ^(1|true|TRUE)$ ]]; then
24+
echo "${cmd[*]} ${*}"$'\n'"${cmd[*]//?/˙} ${*//?/˙}"$'\n'"node $( node -v | tr -d 'v' ) · npm $( npm -v | tr -d 'v' )"$'\n\n'
2325
fi
2426
if (( $# )); then
2527
"${cmd[@]}" "${@}" # :: execute npm command with additional args::
@@ -33,7 +35,7 @@ function nx() ( local pkg="" cmd="" npmcmds=""
3335
# ns -> npm start nk -> npm link ni -> npm install nu -> npm uninstall nis, nid, nus, nud -> npm [un]install --save[-dev]
3436
if ! [[ "${NX_ALIASES}" =~ ^(0|false|FALSE)$ ]]; then
3537
alias "${NX_COMMAND:-n}"='nx'
36-
for word in $( tr -cs '[:alnum:]._-/' ' ' <<< "${NX_ALIASES:-install,uninstall,start,test,build,format,lint,k/link,publish,help}" ); do
38+
for word in $( tr -cs '[:alnum:]._-/' ' ' <<< "${NX_ALIASES:-install,uninstall,start,test,build,format,lint,k/link,publish,help},${NX_EXTEND_ALIASES:-}" ); do
3739
[[ "${NX_COMMAND}" =~ ^(0|false|FALSE)$ ]] && NX_COMMAND='nx'
3840
alias "${NX_COMMAND:-n}${word:0:1}"="nx ${word#[a-z]/}"; [[ -n "${NX_VERBOSE}" ]] && alias "${NX_COMMAND:-n}${word:0:1}"
3941
if [[ "${word}" =~ ^(un)?install$ ]]; then

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nx.sh",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "A minimalist command runner for npm packages, with a focus on developer ergonomics.",
55
"main": "nx.sh",
66
"files": [

0 commit comments

Comments
 (0)