From 2611f521494187a2ef3a87453298fb69c53769ff Mon Sep 17 00:00:00 2001 From: bordun Date: Tue, 28 Apr 2020 14:21:55 +0200 Subject: [PATCH] cli: fix --custom-module check for path including spaces (#619) --- src/server/options.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/server/options.js b/src/server/options.js index d4e159e0..fa6b99ec 100644 --- a/src/server/options.js +++ b/src/server/options.js @@ -19,7 +19,19 @@ module.exports = { }, '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)', check: (arg)=>{ - return fs.existsSync(arg[0]) ? true : 'Custom module file not found: ' + arg + + var customModule = arg.slice() + + // consolidate path containing whitespaces + if (!customModule[0].includes('.js')) { + var index = customModule.findIndex(x => typeof x === 'string' && x.includes('.js')) + if (index !== undefined) { + var _path = customModule.slice(0, index + 1).join(' ') + customModule.splice(0, index + 1, _path) + } + } + + return fs.existsSync(customModule[0]) ? true : 'Custom module file not found: ' + customModule[0] }, }, 'p': {alias: 'port', type: 'number', describe: 'http port of the server (default to 8080)',