Skip to content

Commit 193b220

Browse files
author
Vladimir Kotal
committed
add API blueprint verification
1 parent 480f365 commit 193b220

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

dev/before_install

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22

33
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
44
sudo apt-get update -qq
5-
sudo apt-get install -qq cvs git mercurial cssc bzr subversion monotone rcs rcs-blame python3 python3-pip pep8;
5+
sudo apt-get install -qq cvs git mercurial cssc bzr subversion monotone rcs rcs-blame python3 python3-pip pep8 nodejs;
66
sudo ./dev/install-bitkeeper.sh
77
sudo pip3 install --upgrade pip
88
sudo pip3 install flake8
99
elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
1010
brew update
11-
brew install ctags cvs
11+
brew install ctags cvs node
1212
brew upgrade python
1313
pip3 install pep8 flake8
1414
fi
1515

1616
sudo ./dev/install-universal_ctags.sh
17+
18+
# for API blueprint verification
19+
npm install drafter

dev/parse.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
var drafter = require('drafter');
2+
var fs = require('fs');
3+
4+
new Promise(function(resolve, reject) {
5+
fs.readFile('apiary.apib', 'utf8', (error, data) => {
6+
if (error) {
7+
console.error(error);
8+
reject(1);
9+
}
10+
11+
resolve(data);
12+
});
13+
})
14+
.then(function(data) {
15+
return new Promise((resolve, reject) => {
16+
drafter.parse(data, function(error, result) {
17+
if (error) {
18+
console.log(error);
19+
resolve(1);
20+
return;
21+
} else {
22+
for (x in result.content) {
23+
var d = result.content[x];
24+
// console.log(d);
25+
if (d['element'] != 'category') {
26+
console.log('Error:\n', d);
27+
resolve(1);
28+
return;
29+
}
30+
}
31+
}
32+
33+
console.log("Blueprint check passed");
34+
resolve(0);
35+
});
36+
});
37+
})
38+
.then(process.exit)
39+
.catch(process.exit);

0 commit comments

Comments
 (0)