Guest User

Untitled

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