1var drafter = require('drafter'); 2var fs = require('fs'); 3 4new 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);