1const validateOptions = options => { 2 if (typeof options !== 'object' || !options) { 3 throw new TypeError('invalid options object provided to runScript') 4 } 5 6 const { 7 event, 8 path, 9 scriptShell, 10 env = {}, 11 stdio = 'pipe', 12 args = [], 13 cmd, 14 } = options 15 16 if (!event || typeof event !== 'string') { 17 throw new TypeError('valid event not provided to runScript') 18 } 19 if (!path || typeof path !== 'string') { 20 throw new TypeError('valid path not provided to runScript') 21 } 22 if (scriptShell !== undefined && typeof scriptShell !== 'string') { 23 throw new TypeError('invalid scriptShell option provided to runScript') 24 } 25 if (typeof env !== 'object' || !env) { 26 throw new TypeError('invalid env option provided to runScript') 27 } 28 if (typeof stdio !== 'string' && !Array.isArray(stdio)) { 29 throw new TypeError('invalid stdio option provided to runScript') 30 } 31 if (!Array.isArray(args) || args.some(a => typeof a !== 'string')) { 32 throw new TypeError('invalid args option provided to runScript') 33 } 34 if (cmd !== undefined && typeof cmd !== 'string') { 35 throw new TypeError('invalid cmd option provided to runScript') 36 } 37} 38 39module.exports = validateOptions 40