Last active
May 10, 2022 17:39
-
-
Save giehlman/b6eb3cdb6320a2f4696d854c2f6f9134 to your computer and use it in GitHub Desktop.
Takes the version in package.json and seds it in swagger.yaml
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
# Get the version from package.json | |
PACKAGE_VERSION=$(cat package.json \ | |
| grep version \ | |
| head -1 \ | |
| awk -F: '{ print $2 }' \ | |
| sed 's/[",]//g' \ | |
| tr -d '[[:space:]]') | |
echo "Extracted version: ${PACKAGE_VERSION}" | |
# Find the swagger file | |
SWAGGER_FILE=$(find ./ -iname swagger.yaml -type f) | |
echo "Swagger file found: ${SWAGGER_FILE}" | |
# Now do the replacement in-place (MacOS/Unix compatible) | |
REPLACE='^ version: .*$' | |
WITH=" version: '${PACKAGE_VERSION}'" | |
sed -i.bak "s#${REPLACE}#${WITH}#g" ${SWAGGER_FILE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment