main: allow passing extra options to --custom-module and make them available through global object "options"
This commit is contained in:
parent
e4f05b1ae5
commit
8441a4983e
5 changed files with 9 additions and 5 deletions
|
|
@ -5,6 +5,7 @@
|
|||
- main
|
||||
- `--send` accepts `ip:port` and `domain:port` targets
|
||||
- removed previously deprecated `--sync` option
|
||||
- `--custom-module` now accepts extra options that can be consumed from the custom module
|
||||
|
||||
## 0.40.5
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ The module is executed in a restricted context, only a few globals are available
|
|||
- `clearInterval`: `function(interval)`
|
||||
- `settings.read`: `function(name)`, see [settings.js](https://github.com/jean-emmanuel/open-stage-control/blob/master/app/main/settings.js#L125-L162) for available options
|
||||
- `app`: an [event emitter](https://nodejs.org/api/events.html#events_class_eventemitter) for monitoring the events sent by the different clients. Event names can be found in [callbacks.js](https://github.com/jean-emmanuel/open-stage-control/blob/master/app/main/callbacks.js), callbacks are called with 2 arguments: `data` (object) and `clientId` (string)
|
||||
- `options`: `array` containing the extra options passed to `--custom-module` after the filename
|
||||
|
||||
|
||||
`sendOsc` and `receiveOsc` expect arguments formatted as follow:
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ Below are the available command-line options. Note that when running without any
|
|||
| `-l` | `--load` | session file to load |
|
||||
| | `--state` | state file to load (osc messages will be sent, unless there are other clients connected) |
|
||||
| `-b` | `--blank` | load a blank session and start the editor |
|
||||
| `-c` | `--custom-module` | custom module file to load |
|
||||
| `-c` | `--custom-module` | custom module file to load (custom options can be passed after the filename) |
|
||||
| `-p` | `--port` | http port of the server (default to 8080) |
|
||||
| `-o` | `--osc-port` | osc input port (default to --port) |
|
||||
| | `--tcp-port` | tcp server input port |
|
||||
|
|
|
|||
|
|
@ -17,11 +17,12 @@ class OscServer {
|
|||
this.customModuleEventEmitter = new EventEmitter()
|
||||
this.customModule = (()=>{
|
||||
|
||||
if (!settings.read('customModule')) return false
|
||||
var customModule = settings.read('customModule')
|
||||
if (!customModule) return false
|
||||
|
||||
var file = (()=>{
|
||||
try {
|
||||
return fs.readFileSync(settings.read('customModule'),'utf8')
|
||||
return fs.readFileSync(customModule[0], 'utf8')
|
||||
} catch(err) {
|
||||
console.log('CustomModule Error: File not found: ' + settings.read('customModule'))
|
||||
return false
|
||||
|
|
@ -37,7 +38,8 @@ class OscServer {
|
|||
clearTimeout,
|
||||
setInterval,
|
||||
clearInterval,
|
||||
settings
|
||||
settings,
|
||||
options: customModule.slice(1, customModule.length)
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ var options = {
|
|||
'l':{alias:'load',type:'string',file:{name:'OSC Session (.json)', extensions: ['json', 'js']},describe:'session file to load'},
|
||||
'state':{type:'string',file:{name:'OSC State (.state)', extensions: ['state']},describe:'state file to load'},
|
||||
'b':{alias:'blank',type:'boolean',describe:'load a blank session and start the editor'},
|
||||
'c':{alias:'custom-module',type:'string',file:{name:'OSC Custom module (.js)', extensions: ['js']},describe:'custom module file to load'},
|
||||
'c':{alias:'custom-module',type:'array',file:{name:'OSC Custom module (.js)', extensions: ['js']},describe:'custom module file to load (custom options can be passed after the filename)'},
|
||||
'p':{alias:'port',type:'number',describe:'http port of the server (default to 8080)',
|
||||
check: (p)=>{
|
||||
return (!isNaN(p) && p > 1023 && parseInt(p)===p) ?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue