77# Disable history expansion so '!' doesn't trigger the command. (do we need this?)
88# set +H
99
10+ echo " >>>Running jsfiddle.sh"
11+
1012# Generate JSFiddle output as part of the build process.
1113NAME=$1 # The name of the folder, taken from package.json "build" line.
1214
13- # /Users/[USERNAME]/git/js-api-samples/samples or similar
14- SAMPLES_DIR=" $( cd -- " $( dirname -- " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd ) " # Script directory (/samples)
15- PROJECT_ROOT=$( dirname " $SAMPLES_DIR " ) # Get the parent directory (js-api-samples)
15+ # /Users/[USERNAME]/git/js-api-samples/samples
16+
17+ SCRIPT_DIR=" $( cd -- " $( dirname -- " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd ) " # Script directory (/samples)
18+ PROJECT_ROOT=$( dirname " $SCRIPT_DIR " ) # Get the parent directory (js-api-samples)
1619DIST_DIR=" ${PROJECT_ROOT} /dist"
1720
21+ echo " PROJECT_ROOT: ${PROJECT_ROOT} "
22+ echo " SCRIPT_DIR: ${SCRIPT_DIR} "
23+ echo " DIST_DIR: ${DIST_DIR} "
24+ echo " NAME: ${NAME} "
25+
1826# Create a new folder.
1927mkdir -p " ${DIST_DIR} /samples/${NAME} /jsfiddle"
2028
2129# Copy files
22- echo " Copy ${SAMPLES_DIR } /${NAME} /index.js to ${DIST_DIR} /samples/${NAME} /jsfiddle/index.js"
23- cp " ${SAMPLES_DIR } /${NAME} /index.js" " ${DIST_DIR} /samples/${NAME} /jsfiddle/index.js"
24- cp " ${SAMPLES_DIR } /${NAME} /index.html" " ${DIST_DIR} /samples/${NAME} /jsfiddle/index.html"
25- cp " ${SAMPLES_DIR } /${NAME} /style.css" " ${DIST_DIR} /samples/${NAME} /jsfiddle/style.css"
30+ echo " Copy ${SCRIPT_DIR } /${NAME} /index.js to ${DIST_DIR} /samples/${NAME} /jsfiddle/index.js"
31+ cp " ${SCRIPT_DIR } /${NAME} /index.js" " ${DIST_DIR} /samples/${NAME} /jsfiddle/index.js"
32+ cp " ${SCRIPT_DIR } /${NAME} /index.html" " ${DIST_DIR} /samples/${NAME} /jsfiddle/index.html"
33+ cp " ${SCRIPT_DIR } /${NAME} /style.css" " ${DIST_DIR} /samples/${NAME} /jsfiddle/style.css"
2634
2735# Remove region tags from files by type, since they all have different comment conventions.
36+ # We use a conditional here since sed behaves differently on Linux.
2837echo " Remove region tags from ${DIST_DIR} /samples/${NAME} /jsfiddle/index.js"
29- sed -i " " " s/\/\/ \[START .*]//g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/index.js"
30- sed -i " " " s/\/\/ \[END .*]//g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/index.js"
38+ if [[ " $OSTYPE " == " darwin" * ]]; then
39+ sed -i " " " s/\/\/ \[START .*]//g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/index.js"
40+ sed -i " " " s/\/\/ \[END .*]//g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/index.js"
41+ elif [[ " $OSTYPE " == " linux-gnu" * ]]; then
42+ sed -i " s/\/\/ \[START.*]//g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/index.js"
43+ sed -i " s/\/\/ \[END.*]//g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/index.js"
44+ fi
3145
3246echo " Remove region tags from ${DIST_DIR} /samples/${NAME} /jsfiddle/index.html"
33- sed -i " " " s/<!--\s*\[START .*\]\s*-->//g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/index.html"
34- sed -i " " " s/<!--\s*\[END .*\]\s*-->//g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/index.html"
47+ if [[ " $OSTYPE " == " darwin" * ]]; then
48+ sed -i " " " s/<!--\s*\[START .*\]\s*-->//g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/index.html"
49+ sed -i " " " s/<!--\s*\[END .*\]\s*-->//g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/index.html"
50+ elif [[ " $OSTYPE " == " linux-gnu" * ]]; then
51+ sed -i " s/<!--\s*\[START .*\]\s*-->//g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/index.html"
52+ sed -i " s/<!--\s*\[END .*\]\s*-->//g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/index.html"
53+ fi
3554
3655echo " Remove region tags from ${DIST_DIR} /samples/${NAME} /jsfiddle/style.css"
37- sed -i " " " s/\/\* \[START maps_.*] \*\///g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/style.css"
38- sed -i " " " s/\/\* \[END maps_.*] \*\///g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/style.css"
56+ if [[ " $OSTYPE " == " darwin" * ]]; then
57+ sed -i " " " s/\/\* \[START maps_.*] \*\///g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/style.css"
58+ sed -i " " " s/\/\* \[END maps_.*] \*\///g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/style.css"
59+ elif [[ " $OSTYPE " == " linux-gnu" * ]]; then
60+ sed -i " s/\/\* \[START maps_.*] \*\///g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/style.css"
61+ sed -i " s/\/\* \[END maps_.*] \*\///g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/style.css"
62+ fi
3963
4064# Generate demo.details.
4165echo " Generate ${DIST_DIR} /samples/${NAME} /jsfiddle/demo.details"
@@ -44,7 +68,7 @@ cat > "${DIST_DIR}/samples/${NAME}/jsfiddle/demo.details" << EOF
4468name: ${NAME}
4569authors:
4670 - Geo Developer IX Documentation Team
47- tags:s
71+ tags:
4872 - google maps
4973load_type: h
5074description: Sample code supporting Google Maps Platform JavaScript API documentation.
0 commit comments