From c2f87c6cc2197b3c8539c908d22ee24d791df70e Mon Sep 17 00:00:00 2001 From: nrew225 Date: Tue, 25 Oct 2016 16:52:07 -0700 Subject: [PATCH] Add syntax checks to Dangerfile --- Dangerfile | 8 ++++++++ README.md | 2 +- test.js | 11 +++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Dangerfile b/Dangerfile index 9baaf96d..73789df7 100644 --- a/Dangerfile +++ b/Dangerfile @@ -9,6 +9,14 @@ warn 'Please rebase to get rid of the merge commits in this Pull Request' if git require 'json' results = File.read 'ab-results-README.md-markdown-table.json' j = JSON.parse results +if j['error']==true + fail j['title'] + markdown j['message'] + +# Check syntx +require 'json' +results = File.read 'syntaxcheck.json' +j = JSON.parse results if j['error']==true fail j['title'] markdown j['message'] diff --git a/README.md b/README.md index a654257b..bd1bbefb 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ See [Contributing](#contributing). _Web Analytics_ - * [AWStats](http://www.awstats.org/) - Generates web, streaming, ftp or mail server statistics graphically. ([Source Code](https://github.com/eldy/awstats)) `GPLv3` `Perl` + * [AWStats](http://www.awstats.org/) Generates web, streaming, ftp or mail server statistics graphically. ([Source Code](https://github.com/eldy/awstats)) `GPLv3` `Perl` * [Countly](https://count.ly) - Real time mobile & web analytics, crash reporting and push notifications platform. ([Source Code](https://github.com/countly)) `AGPLv3` `Javascript` * [Druid](http://druid.io/) - A distributed, column-oriented, real-time analytics data store. ([Source Code](https://github.com/druid-io/druid/)) `Apache` `Java` * [GoAccess](http://goaccess.io/) - Real-time web log analyzer and interactive viewer that runs in a terminal. ([Source Code](https://github.com/allinurl/goaccess)) `GPLv2` `C` diff --git a/test.js b/test.js index 88cc9ced..94818cc0 100644 --- a/test.js +++ b/test.js @@ -1,5 +1,7 @@ const fs = require('fs'); var testStatus; +var log = "{\n"; +var issuelog = '"message": "Line | Entry\\n----|----------------------\\n'; var file = fs.readFileSync('README.md', 'utf8') entryErrorCheck(file); @@ -28,17 +30,22 @@ function entryErrorCheck(md) { totalPass += 1; //console.log(i + 1 + ". Pass: " + entryArray[i].name); } else { - console.log("Line #" + (i + 1) + ". Fail: " + entryArray[i].name); + console.log("Line #" + (i + 1) + ". Fail: " + entryArray[i].name + "\\n"); //console.log(entries[i]); totalFail += 1; + issuelog += (i + 1) + " | " + entryArray[i].name; } } } if (totalFail > 0) { console.log(totalFail + " Failed, " + totalPass + " Passed, of " + total); + log += '"error": "true",\n"title": "Found ' + totalFail + ' syntax error(s).",\n'; + fs.writeFileSync('syntaxcheck.json', log + issuelog + '"\n}'); process.exit(1); } else { - console.log(totalFail + " Failed, " + totalPass + " Passed, of " + total); + console.log(totalFail + " Failed, " + totalPass + " Passed, of " + total + "\n"); + log += '"error": false,\n"title": "No errors found!"\n}'; + fs.writeFileSync('syntaxcheck.json', log); process.exit(0); } //console.log(entries[i])