FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
wolfcms-tools/phpmini/phpmini.sh at master · wolfcms/wolfcms-tools · GitHub
This repository was archived by the owner on Apr 7, 2021. It is now read-only.
wolfcms
/
wolfcms-tools
Public archive
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Pull requests
0
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Security and quality
Insights
Expand file tree
Breadcrumbs
wolfcms-tools
/
phpmini
/
phpmini.sh
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
119 lines (107 loc) · 2.57 KB
Breadcrumbs
wolfcms-tools
/
phpmini
/
phpmini.sh
Copy path
File metadata and controls
executable file
·
119 lines (107 loc) · 2.57 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!
/bin/bash
#
##
#
## phpmini.sh
#
##
#
## intended to minify php files in the given directory and all subdirs.
#
## it is NOT intended to obfuscate. It is for filesize reduction only.
#
##
#
## written for Wolf CMS by Martijn van der Kleijn, 2012
#
## contact <martijn.niji@gmail.com>
#
##
#
## script licensed under MIT
#
##
#
Displays help message
function
show_help
{
cat
<<
HELPEND
Usage:
`
basename
$0
`
options
-d <directory> Use the given directory as the search base, otherwise the current working directory is assumed.
-e <extension> Search for PHP files with given extension. Defaults to '.php'.
-k Keep the original files by appending '.orig' to the filename.
-K <extension> Use the given extension when keeping the original files instead of the default '.orig' extension.
-v Be verbose and display what is happening.
-t Test mode; does not run any command but simply tells what it would have done.
-h Display help message
HELPEND
}
#
Setup some vars
OPTION_STRING=
'
h?vtkK:d:e:
'
BASE_DIR=.
BAK_EXT=.orig
PHP_EXT=.php
keep=0
keepe=0
verbose=0
testing=0
while
getopts
${OPTION_STRING}
opt
;
do
case
$opt
in
h|
\?
)
show_help
>&2
;
exit
0
;
;;
d)
BASE_DIR=
${OPTARG}
;
;;
e)
PHP_EXT=
${OPTARG}
;
;;
k|K)
if
[
$opt
=
"
K
"
]
;
then
keepe=1
;
BAK_EXT=
"
${OPTARG}
"
;
else
keep=1
;
fi
;;
v)
verbose=1
;
;;
t)
testing=1
;
verbose=1
;
;;
*
)
echo
"
Invalid option: -
$opt
${OPTARG}
"
>&2
;
show_help
;
exit
0
;
;;
esac
done
#
Do the actual work
find
${BASE_DIR}
-type f -name
"
*
${PHP_EXT}
"
|
while
read
FILE
do
if
[
$testing
-eq
1 ]
;
then
echo
"
TEST MODE:
"
else
echo
"
MINIFYING
${FILE}
"
fi
#
create minified versions
if
[
$testing
-eq
0 ]
;
then
php -w
${FILE}
>
${FILE}
.mini
fi
if
[
$verbose
-eq
1 ]
;
then
echo
"
- Created minified version of
${FILE}
"
fi
if
[
$keep
-eq
1 ]
||
[
$keepe
-eq
1 ]
then
if
[
$testing
-eq
0 ]
;
then
mv
${FILE}
${FILE}${BAK_EXT}
fi
if
[
$verbose
-eq
1 ]
;
then
echo
"
- Moved original file to
${FILE}${BAK_EXT}
"
fi
else
if
[
$testing
-eq
0 ]
;
then
rm -f
${FILE}
fi
if
[
$verbose
-eq
1 ]
;
then
echo
"
- Removed original file
"
fi
fi
#
Rename mini to orig name
if
[
$testing
-eq
0 ]
;
then
mv
${FILE}
.mini
${FILE}
fi
if
[
$verbose
-eq
1 ]
;
then
echo
"
- Renamed minified file
${FILE}
.mini to
${FILE}
"
fi
done
Back
|
FazBrowse Home
|
New Git URL