Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This is used to parse key, val pairs from a json file - in my case a asset-manifest.json file
- function jsonValue() {
- KEY=$1
- num=$2
- awk -F"[,:}]" '{for(i=1;i<=NF;i++){if($i~/'$KEY'\042/){print $(i+1)}}}' | tr -d '"[:space:]' | sed -n ${num}p
- }
- # This is source map file name which is the value matching the key `main.js.map` in the above mentioned json file
- map_file_name=$(cat build/asset-manifest.json | jsonValue main.js.map)
- # This saves the the file name (static/js/main.EXAMPLE.js.map) string now accessible in variable $map_file_name
- # Can be used in a curl call but in gist we'll just echo it
- echo $map_file_name
Add Comment
Please, Sign In to add comment