-
Notifications
You must be signed in to change notification settings - Fork 1
/
update.sh
executable file
·30 lines (26 loc) · 1.07 KB
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
# Find the generated bundled assets of your Material version
# and insert it into `codelab/base.html`
cwd=$(pwd)
loc=$(pip show mkdocs-material | grep -Po '(?<=Location: )(.*)' )
echo $loc
v=$( pip show mkdocs-material | grep -Po '(?<=Version: )(\S*)')
echo $v
dir="$loc/mkdocs_material-$v.dist-info/RECORD"
echo $dir
CSS_BUNDLE=$( grep -Po '(?<=material/templates/)(.*main\..*\.min.css)(?=,)' $dir )
PAL_BUNDLE=$( grep -Po '(?<=material/templates/)(.*palette\..*\.min.css)(?=,)' $dir )
SW_BUNDLE=$( grep -Po '(?<=material/templates/)(.*search\..*\.min.js)(?=,)' $dir )
JS_BUNDLE=$( grep -Po '(?<=material/templates/)(.*bundle\..*\.min.js)(?=,)' $dir )
echo $CSS_BUNDLE
echo $PAL_BUNDLE
echo $SW_BUNDLE
echo $JS_BUNDLE
base='codelab/base.html'
cp 'codelab/base-custom.html' $base
sed -i -E "s:assets\/.*\/main\.\S*\.min\.css:$CSS_BUNDLE:g" $base
sed -i -E "s:assets\/.*\/palette\.\S*\.min\.css:$PAL_BUNDLE:g" $base
sed -i -E "s:assets\/.*\/search\.\S*\.min\.js:$SW_BUNDLE:g" $base
sed -i -E "s:assets\/.*\/bundle\.\S*\.min\.js:$JS_BUNDLE:g" $base
cd $cwd
echo "Updated $base"