source: trip-planner-front/node_modules/@npmcli/run-script/lib/validate-options.js@ 59329aa

Last change on this file since 59329aa was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1const validateOptions = options => {
2 if (typeof options !== 'object' || !options)
3 throw new TypeError('invalid options object provided to runScript')
4
5 const {
6 event,
7 path,
8 scriptShell,
9 env = {},
10 stdio = 'pipe',
11 args = [],
12 cmd,
13 } = options
14
15 if (!event || typeof event !== 'string')
16 throw new TypeError('valid event not provided to runScript')
17 if (!path || typeof path !== 'string')
18 throw new TypeError('valid path not provided to runScript')
19 if (scriptShell !== undefined && typeof scriptShell !== 'string')
20 throw new TypeError('invalid scriptShell option provided to runScript')
21 if (typeof env !== 'object' || !env)
22 throw new TypeError('invalid env option provided to runScript')
23 if (typeof stdio !== 'string' && !Array.isArray(stdio))
24 throw new TypeError('invalid stdio option provided to runScript')
25 if (!Array.isArray(args) || args.some(a => typeof a !== 'string'))
26 throw new TypeError('invalid args option provided to runScript')
27 if (cmd !== undefined && typeof cmd !== 'string')
28 throw new TypeError('invalid cmd option provided to runScript')
29}
30
31module.exports = validateOptions
Note: See TracBrowser for help on using the repository browser.