Last active
August 29, 2015 14:28
-
-
Save gorhgorh/9695a5788c36090f79d7 to your computer and use it in GitHub Desktop.
simple novce version check vs required version (could be used to check adapt's min version vs current one)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_maxNodeVer": "0.10.33", | |
"_defaultLanguage": "en", | |
"_defaultDirection": "ltr", | |
"_questionWeight": 1, | |
"_accessibility": { | |
"_isEnabled": true, | |
"_shouldSupportLegacyBrowsers": true, | |
"_isTextProcessorEnabled": true | |
}, | |
"_drawer": { | |
"_showEasing": "easeOutQuart", | |
"_hideEasing": "easeInQuart", | |
"_duration": 400 | |
}, | |
"_spoor": { | |
"_isEnabled": true, | |
"_tracking": { | |
"_requireCourseCompleted": true, | |
"_requireAssessmentPassed": true, | |
"_shouldSubmitScore": false | |
}, | |
"_reporting": { | |
"_comment": "Your options here are 'completed', 'passed', 'failed', and 'incomplete'", | |
"_onTrackingCriteriaMet": "completed", | |
"_onAssessmentFailure": "incomplete" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var path = require('path'); | |
var curVer = process.versions.node; | |
var confObj; | |
function checkVersion(curr,rec){ | |
var currArr = curr.split('.'); | |
var requArr = rec.split('.'); | |
if(currArr[0] > requArr[0] || | |
(currArr[0] <= requArr[0] && currArr[1] > requArr[1]) || | |
(currArr[0] <= requArr[0] && currArr[1] <= requArr[1] && currArr[2] > requArr[2]) | |
){ | |
var errMsg = 'you should use node version ' + rec + ' you are currently using '+ curr; | |
throw errMsg; | |
}else{ | |
console.log('correct version of node used'); | |
} | |
} | |
confObj = fs.readFile('./src/course/config.json','utf8', function (err, data) { | |
if (err) throw err; | |
confObj = JSON.parse(data); | |
if(!confObj._maxNodeVer){ | |
console.log("no min version defined, max node.js version 0.10.33"); | |
confVer = '0.10.32'; | |
}else{ | |
confVer = confObj._maxNodeVer; | |
} | |
checkVersion(curVer,confVer); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment