-
Notifications
You must be signed in to change notification settings - Fork 8
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
3 changed files
with
39 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
# Developed with the help of ChatGPT | ||
|
||
# Set the locale for the script to the C locale | ||
export LC_ALL=C | ||
|
||
# Path to your package.json file | ||
PACKAGE_JSON_PATH="./package.json" | ||
|
||
# Path to TypeScript command | ||
TSC="./node_modules/.bin/tsc" | ||
|
||
# Directory containing the files for replacement | ||
DIST_DIR="./dist" | ||
|
||
# Use grep with a regular expression to extract the version number | ||
VERSION=$(grep '"version":' "$PACKAGE_JSON_PATH" | sed -E 's/.*"version": "([^"]+)",?/\1/') | ||
|
||
if [ -z "$VERSION" ]; then | ||
echo "Version number not found." | ||
exit 1 | ||
fi | ||
|
||
echo -e "\nBuilding the CommonJS library folder..." | ||
$TSC -p tsconfig-cjs.json | ||
|
||
echo -e "\nBuilding the ES6 library folder..." | ||
$TSC -p tsconfig-esm.json | ||
|
||
# Replace all occurrences of __PACKAGE_VERSION__ in files within the dist directory | ||
echo -e "\nSetting the version number to '$VERSION'..." | ||
find "$DIST_DIR" -type f -exec sed -i '' -e "s/__PACKAGE_VERSION__/$VERSION/g" {} + | ||
|
||
echo -e "\nBuild complete\n" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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