Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
add testing of all json file, linting of main js and gulp as test
Browse files Browse the repository at this point in the history
  • Loading branch information
butlerx committed Oct 2, 2016
1 parent 5f04d50 commit 9ae1a21
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"json"
],
"env": {
"browser": true
"browser": true,
"jquery": true
},
"extends": "eslint:recommended",
"rules": {
Expand Down
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: node_js
node_js:
- "node"
- "6"
- "5"
- "4"
22 changes: 15 additions & 7 deletions bin/check-event-json
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
#!/usr/bin/env node

var fs = require("fs");
var filename = process.argv[2];
var fs = require('fs');
var file = process.argv[2];

if (filename) {
if(file !== undefined && file !== null) {
checkJson(file);
} else {
for(var i of ['events.json', '2015/events.json', '2016/events.json']) {
checkJson(i);
}
process.exit(0);
}

function checkJson (filename) {
try {
JSON.parse(fs.readFileSync(filename, "utf8"));
console.log("Look good");
JSON.parse(fs.readFileSync(filename, 'utf8'));
console.log(filename + ' look good');
} catch (err) {
console.error(err);
process.exit(1);
}
} else {
console.log("Usage: check-event-json events.json");
}
6 changes: 3 additions & 3 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ function loadEvents(days){
var ce = $('.card-container__events');
for(var i = 0; i < days.length; i++) {
var day = days[i];
var ds = day.day+'-event';
var ul = day.day+'-events';
var de = $('<li><div id="'+day.day+'" class="collapsible-header container day"><h5 class="day__title" data-position="right"><span class="day__title__bold">' + day.day + '</span> - ' + day.description + '</h5></div><div class="collapsible-body"><ul id="'+ul+'"class="collapsible sub-collapsible" data-collepsible="accordion"></div></ul>').appendTo(ce);
var ul = day.day + '-events';
var de = $('<li><div id="' + day.day + '" class="collapsible-header container day"><h5 class="day__title" data-position="right"><span class="day__title__bold">' + day.day + '</span> - ' + day.description + '</h5></div><div class="collapsible-body"><ul id="'+ul+'"class="collapsible sub-collapsible" data-collepsible="accordion"></div></ul>');
de.appendTo(ce);

for(var j = 0; j < day.events.length; j++) {
var event = day.events[j];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "This repository contains the Techweek website",
"main": "gulpfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"test": "eslint js/main,js && bin/check-event-json && gulp",
"postinstall": "gulp"
},
"repository": {
Expand Down

0 comments on commit 9ae1a21

Please sign in to comment.