This repository was archived by the owner on Mar 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathcache.sh
More file actions
executable file
·89 lines (77 loc) · 2.28 KB
/
Copy pathcache.sh
File metadata and controls
executable file
·89 lines (77 loc) · 2.28 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash
set -e -o pipefail
cd `dirname $0`/..
BASE="public/docs/ts"
LATEST="$BASE/latest"
CACHE="$BASE/_cache"
FILES="
guide/architecture.jade
guide/attribute-directives.jade
guide/component-styles.jade
guide/dependency-injection.jade
guide/displaying-data.jade
guide/hierarchical-dependency-injection.jade
guide/lifecycle-hooks.jade
guide/pipes.jade
guide/security.jade
guide/server-communication.jade
guide/structural-directives.jade
guide/template-syntax.jade
glossary.jade
quickstart.jade
tutorial/toh-pt5.jade
tutorial/toh-pt6.jade"
function cacheRefresh() {
local FILE_PATTERN="*"
if [[ -n "$1" ]]; then
FILE_PATTERN="$1"
else
echo "Argument missing: specify shell file glob pattern of files to be refreshed."
exit 1;
fi
local allFound=true;
for f in $FILES; do
local srcPath="$LATEST/$f";
local destPath="$CACHE/$f";
local destDir=`dirname $destPath`;
if [[ -e $srcPath ]]; then
[[ -d "$destDir" ]] || (set -x; mkdir $destDir);
case "$f" in
(*$FILE_PATTERN*)
(set -x; cp $srcPath $destPath);;
(*)
echo "SKIPPED $f";;
esac
else
echo Cannot find $srcPath
allFound=false;
fi
done
[[ $allFound ]] || exit 1;
}
function cacheDiffSummary() {
diff -qr -x "_*.*" "$CACHE/" "$LATEST/" | \
grep -v "^Only in"
}
function cacheDiff() {
local FILES="*$1*"
cd $CACHE;
# List files
find . -name "$FILES" ! -name "*~" -exec diff -q {} ../latest/{} \;
# Show differences
find . -name "$FILES" ! -name "*~" -exec diff {} ../latest/{} \;
}
function usage() {
echo "Usage: cache.sh [options]"
echo " (-ds|--diff-summary) list names of cache files that differ from ts/latest"
echo " (-d|--diff) pat diff cache and latest subdirectories"
echo " (-l|--list) list files subject to caching"
echo " (-r|--refresh) pat refresh files in cache matching pattern"
}
case "$1" in
(-ds|--diff-summary) shift; cacheDiffSummary $@;;
(-d|--diff) shift; cacheDiff $@;;
(-l|--list) shift; printf "$FILES\n\n";;
(-r|--refresh) shift; cacheRefresh $@;;
(*) usage;
esac