launcher: accept json session files and print a deprecation warning in the console (issue #101)

This commit is contained in:
bordun 2017-09-16 14:10:27 +02:00
parent 2a319b85fb
commit a941ac621b
3 changed files with 8 additions and 3 deletions

View file

@ -63,10 +63,15 @@ module.exports = {
},
sessionOpen: function(data,clientId) {
var file = data.file || (function(){try {return fs.readFileSync(data.path,'utf8')} catch(err) {return false}})(),
error = file===false&&data.path?'Session file "' + data.path + '" not found.':false,
session
if (data.path && data.path.split('.').pop() == 'js') {
console.warn(`Warning: support for .js session files is deprecated, please use the .json extension instead`)
}
try {
session = vm.runInNewContext(file)
} catch(err) {