diff --git a/app/main/callbacks.js b/app/main/callbacks.js index be91e8b5..d6522ee5 100644 --- a/app/main/callbacks.js +++ b/app/main/callbacks.js @@ -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) { diff --git a/app/main/launcher/launcher.js b/app/main/launcher/launcher.js index d0eaa4fa..07fd8b51 100644 --- a/app/main/launcher/launcher.js +++ b/app/main/launcher/launcher.js @@ -57,7 +57,7 @@ $(document).ready(()=>{ browse.click(function(e){ e.preventDefault() - dialog.showOpenDialog({filters:[{name:'js',extensions:['js']}]},function(file){ + dialog.showOpenDialog({filters:[{name:option.file.name,extensions:option.file.extensions}]},function(file){ input.val(file).change() }) }) diff --git a/app/main/settings.js b/app/main/settings.js index 435c126f..0e4fa0f0 100644 --- a/app/main/settings.js +++ b/app/main/settings.js @@ -13,9 +13,9 @@ var options = { true : 'Sync hosts must be ip:port pairs & port must be >= 1024' } }, - 'l':{alias:'load',type:'string',file:'js',describe:'session file to load'}, + 'l':{alias:'load',type:'string',file:{name:'OSC Session (.json)', extensions: ['json', 'js']},describe:'session file to load'}, 'b':{alias:'blank',type:'boolean',describe:'load a blank session and start the editor'}, - 'c':{alias:'custom-module',type:'string',file:'js',describe:'custom module file to load'}, + 'c':{alias:'custom-module',type:'string',file:{name:'OSC Custom module (.js)', extensions: ['js']},describe:'custom module file to load'}, 'p':{alias:'port',type:'number',describe:'http port of the server (default to 8080)', check: (p)=>{ return (!isNaN(p) && p > 1023 && parseInt(p)===p) ?