forked from QingCloudAppcenter/user-guide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·38 lines (33 loc) · 1012 Bytes
/
test.sh
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
#!/bin/bash
PWD=`pwd`
set +x
function test_by_docker {
docker rm -f nodejs_guide
docker run -d -it --name nodejs_guide -v ${PWD}/docs:/tmp/docs node:alpine /bin/sh
docker cp markdownlint.conf.json nodejs_guide:/tmp/
docker exec -it nodejs_guide npm install -g markdownlint-cli --registry=https://registry.npm.taobao.org
docker exec -it nodejs_guide markdownlint --config /tmp/markdownlint.conf.json /tmp/docs/
docker rm -f nodejs_guide
}
function test_by_nodejs {
markdownlint --config markdownlint.conf.json docs/
if [[ $? == 1 ]]; then
echo -e "\n"
echo -e "\n"
echo -e "\n"
echo "please refer to https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md"
fi
}
set -x
if type docker &> /dev/null; then
test_by_docker
elif type node &> /dev/null; then
if ! type markdownlint &> /dev/null; then
npm install -g markdownlint-cli --registry=https://registry.npm.taobao.org
fi
test_by_nodejs
else
echo "Failed, no docker or nodejs env"
fi
echo "Done"
exit 0