-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathreplace-namespace.sh
More file actions
executable file
·59 lines (43 loc) · 1.27 KB
/
replace-namespace.sh
File metadata and controls
executable file
·59 lines (43 loc) · 1.27 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
#!/usr/bin/env bash
set -eou pipefail
#
# Ensure unique namespace by replacing ScssPhp\ScssPhp with Tangible\ScssPhp
#
# This is necessary because PHP and Composer don't support different versions
# of the same module.
#
main() {
local OS
local CURRENT_FOLDER="scssphp"
OS="$(uname)"
namespace-files() {
echo "Folder: $CURRENT_FOLDER"
local RESTORE_FOLDER="$CURRENT_FOLDER"
for file in *.php; do
echo " File: $file";
if [ "$OS" == "Darwin" ]; then
# macOS-specific options for sed
# @see https://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux#22084103
sed -i '' -e 's/namespace\ ScssPhp\\/namespace\ Tangible\\/g' "$file"
sed -i '' -e 's/use\ ScssPhp\\/use\ Tangible\\/g' "$file"
else
# Linux or WSL2 - Windows Subsystem for Linux
sed -i -e 's/namespace\ ScssPhp\\/namespace\ Tangible\\/g' "$file"
sed -i -e 's/use\ ScssPhp\\/use\ Tangible\\/g' "$file"
fi
done
for folder in *; do
if [ -d "$folder" ]; then
CURRENT_FOLDER="$RESTORE_FOLDER/$folder"
cd "$folder"
namespace-files
cd ..
fi
done
CURRENT_FOLDER="$RESTORE_FOLDER"
}
cd scssphp
namespace-files
cd ..
}
main