Mehuge/nps-plus

Parse nps args before calling function.

Closed this issue · 2 comments

At present, nps-plus passes input directly to the script. It would be better if input was pre-parsed, so that args are passed as a second args parameter, with the input being just the script name. The function signature for a function as script would therefore be

function something(name, args) {
  ...
}

Example:

module.exports = {
  scripts: {
    wait: 'task1 "sleep 1000" task2',
    sleep: (scriptName, args) => new Promise((resolve, reject) => {
      setTimeout(resolve, args[0] | 0)
    })
  }
};