Skip to content

Instantly share code, notes, and snippets.

@wojpawlik
Created August 6, 2023 13:28
Show Gist options
  • Save wojpawlik/e297c5b8e9fa795dfb4d0a9a57cfb7f0 to your computer and use it in GitHub Desktop.
Save wojpawlik/e297c5b8e9fa795dfb4d0a9a57cfb7f0 to your computer and use it in GitHub Desktop.
#!/bin/bash -eu
export PATH="$PWD/node_modules/.bin:$PATH"
name="$1"
shift
args="${*@Q}"
if cmd="$(jq --raw-output --exit-status --arg name "pre$name" '.scripts[$name]' package.json)"; then
echo "> $cmd"
eval "$cmd"
fi
cmd="$(jq --raw-output --exit-status --arg name "$name" '.scripts[$name]' package.json)"
echo "> $cmd $args"
eval "$cmd $args"
if cmd="$(jq --raw-output --exit-status --arg name "post$name" '.scripts[$name]' package.json)"; then
echo "> $cmd"
eval "$cmd"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment