Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit de41148

Browse files
chalinkwalrath
authored andcommitted
chore(cache): cache management script (#2090)
Cf. #2088.
1 parent 596b686 commit de41148

File tree

2 files changed

+74
-44
lines changed

2 files changed

+74
-44
lines changed

scripts/cache.sh

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env bash
2+
3+
set -e -o pipefail
4+
5+
BASE="public/docs/ts"
6+
LATEST="$BASE/latest"
7+
CACHE="$BASE/_cache"
8+
9+
FILES="
10+
guide/architecture.jade
11+
guide/attribute-directives.jade
12+
guide/component-styles.jade
13+
guide/dependency-injection.jade
14+
guide/displaying-data.jade
15+
guide/hierarchical-dependency-injection.jade
16+
guide/lifecycle-hooks.jade
17+
guide/pipes.jade
18+
guide/security.jade
19+
guide/server-communication.jade
20+
guide/structural-directives.jade
21+
guide/template-syntax.jade
22+
quickstart.jade
23+
tutorial/toh-pt6.jade"
24+
25+
function cacheRefresh() {
26+
local FILE_PATTERN="*"
27+
if [[ -n "$1" ]]; then
28+
FILE_PATTERN="$1"
29+
else
30+
echo "Argument missing: specify shell file glob pattern of files to be refreshed."
31+
exit 1;
32+
fi
33+
34+
local allFound=true;
35+
36+
for f in $FILES; do
37+
local srcPath="$LATEST/$f";
38+
local destPath="$CACHE/$f";
39+
local destDir=`dirname $destPath`;
40+
if [[ -e $srcPath ]]; then
41+
[[ -d "$destDir" ]] || (set -x; mkdir $destDir);
42+
case "$f" in
43+
($FILE_PATTERN)
44+
(set -x; cp $srcPath $destPath);;
45+
(*)
46+
echo "SKIPPED $f";;
47+
esac
48+
else
49+
echo Cannot find $srcPath
50+
allFound=false;
51+
fi
52+
done
53+
54+
[[ $allFound ]] || exit 1;
55+
}
56+
57+
function cacheDiff() {
58+
diff -qr -x "_*.*" "$CACHE/" "$LATEST/" | \
59+
grep -v "^Only in"
60+
}
61+
62+
function usage() {
63+
echo "Usage: cache.sh [-d | -l | -r pattern]"
64+
echo " -d diff cache and latest subdirectories"
65+
echo " -l list files subject to caching"
66+
echo " -r pat refresh files in cache matching pattern"
67+
}
68+
69+
case "$1" in
70+
(-r) shift; cacheRefresh $@;;
71+
(-d) shift; cacheDiff $@;;
72+
(-l) shift; printf "$FILES\n\n";;
73+
(*) usage;
74+
esac

scripts/refresh-cache.sh

-44
This file was deleted.

0 commit comments

Comments
 (0)