Skip to content

Commit 14f9271

Browse files
authored
Merge pull request #154 from rackerlabs/docs-util
docs(util): add util JS for code snippets
2 parents b81abb3 + cdde240 commit 14f9271

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

docs/_util.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
function stripIndent (rawString) {
2+
const match = rawString.match(/^[ \t]*(?=\S)/gm);
3+
4+
if (!match) {
5+
return rawString;
6+
}
7+
8+
const minIndent = Math.min.apply(Math, match.map(x => x.length));
9+
10+
const reMinIndent = new RegExp(`^[ \\t]{${minIndent}}`, 'gm');
11+
12+
let strReindented = rawString;
13+
if (minIndent > 0) {
14+
strReindented = rawString.replace(reMinIndent, '');
15+
}
16+
17+
return strReindented.trim();
18+
}//stripIndent()
19+
20+
function snippet (raw) {
21+
// https://regex101.com/r/hKMzZP/4
22+
let normalized = raw.replace(/(\s+^\s+$|\s+(?=>))/gm, '');
23+
return stripIndent(normalized);
24+
}
25+
26+
export default {
27+
snippet,
28+
};

test/scripts/webdriver-update

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ platform_chrome='linux64'
2222
[ `uname` == 'Darwin' ] && platform_gecko='macos' && platform_chrome='mac64'
2323

2424
TARFILE_GECKO=v0.18.0/geckodriver-v0.18.0-${platform_gecko}.tar.gz
25-
TARFILE_CHROME=2.34/chromedriver_${platform_chrome}.zip
25+
TARFILE_CHROME=2.35/chromedriver_${platform_chrome}.zip
2626
TARFILE_STANDALONE='3.4/selenium-server-standalone-3.4.0.jar'
2727

2828
if [ $reinstall == "1" ] || [ $has_gecko == "0" ]; then
@@ -33,8 +33,8 @@ fi
3333

3434
if [ $reinstall == "1" ] || [ $has_chrome == "0" ]; then
3535
echo Downloading ${TARFILE_CHROME}
36-
wget -nc -q https://chromedriver.storage.googleapis.com/${TARFILE_CHROME} -O bin/selenium/chromedriver_2.34.zip
37-
unzip -o bin/selenium/chromedriver_2.34.zip -d bin/selenium/
36+
wget -nc -q https://chromedriver.storage.googleapis.com/${TARFILE_CHROME} -O bin/selenium/chromedriver_2.35.zip
37+
unzip -o bin/selenium/chromedriver_2.35.zip -d bin/selenium/
3838
fi
3939

4040
if [ $reinstall == "1" ] || [ $has_chrome == "0" ]; then

0 commit comments

Comments
 (0)