-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
19 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
# make sure the script runs relative to the repo root | ||
set -euo pipefail && cd "$(dirname "${BASH_SOURCE[0]}")/.." | ||
# Ensure script runs relative to the repo root | ||
set -euo pipefail | ||
cd "$(dirname "${BASH_SOURCE[0]}")/.." | ||
|
||
# some helpers and error handling: | ||
info() { printf "%s\n" "$*" >&1; } | ||
error() { printf "%s\n" "$*" >&2; } | ||
trap 'echo Changeset interrupted >&2; exit 2' INT TERM | ||
# Trap signals for graceful exit | ||
trap 'echo "Script interrupted" >&2; exit 2' INT TERM | ||
|
||
# pass all arguments to changeset | ||
./node_modules/.bin/changeset "$@" | ||
# Run changeset with passed arguments | ||
npx changeset "$@" | ||
exitCode=$? | ||
|
||
changeset_exit=$? | ||
if [ ${changeset_exit} -gt 0 ]; | ||
then | ||
error "Changeset finished with error" | ||
exit ${changeset_exit} | ||
if [ $exitCode -ne 0 ]; then | ||
echo "Changeset finished with error" >&2 | ||
exit $exitCode | ||
fi | ||
|
||
# if first argument was `version` also run the `update-version.ts` script | ||
args=("$@") | ||
info "args: ${args[@]}" | ||
if [ $# -gt 0 ] && [ ${args[0]} = "version" ] | ||
then | ||
yarn tsx scripts/update-version.ts | ||
# Handle "post" scripts if arguments are provided | ||
if [ $# -gt 0 ]; then | ||
command="$1" | ||
shift # Remove the first argument from $@ | ||
script="changeset:post${command}" | ||
echo "Running post script: ${script}" | ||
npm run "${script}" --if-present -- "$@" | ||
fi |