Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse and validate all cli arguments before launching pa11y #529

Open
josebolos opened this issue Aug 18, 2020 · 0 comments
Open

Parse and validate all cli arguments before launching pa11y #529

josebolos opened this issue Aug 18, 2020 · 0 comments

Comments

@josebolos
Copy link
Member

When launching pa11y from the command line with an invalid runner as an argument, pa11y crashes instead of returning a helpful error message.

$ pa11y --runner potato https://www.nature.com

Welcome to Pa11y

 > Running Pa11y on URL https://www.nature.com
(node:4782) UnhandledPromiseRejectionWarning: Error: Cannot find module 'potato'
Require stack:
- /Users/jose.bolos/.nvm/versions/node/v12.18.3/lib/node_modules/pa11y/lib/pa11y.js
- /Users/jose.bolos/.nvm/versions/node/v12.18.3/lib/node_modules/pa11y/bin/pa11y.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at loadRunnerFile (/Users/jose.bolos/.nvm/versions/node/v12.18.3/lib/node_modules/pa11y/lib/pa11y.js:445:9)
    at loadRunnerScript (/Users/jose.bolos/.nvm/versions/node/v12.18.3/lib/node_modules/pa11y/lib/pa11y.js:474:23)
    at injectRunners (/Users/jose.bolos/.nvm/versions/node/v12.18.3/lib/node_modules/pa11y/lib/pa11y.js:330:39)
    at runPa11yTest (/Users/jose.bolos/.nvm/versions/node/v12.18.3/lib/node_modules/pa11y/lib/pa11y.js:124:8)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async pa11y (/Users/jose.bolos/.nvm/versions/node/v12.18.3/lib/node_modules/pa11y/lib/pa11y.js:39:18)
(node:4782) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:4782) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:4782) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)

Error: Cannot find module 'potato'
Require stack:
- /Users/jose.bolos/.nvm/versions/node/v12.18.3/lib/node_modules/pa11y/lib/pa11y.js
- /Users/jose.bolos/.nvm/versions/node/v12.18.3/lib/node_modules/pa11y/bin/pa11y.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at loadRunnerFile (/Users/jose.bolos/.nvm/versions/node/v12.18.3/lib/node_modules/pa11y/lib/pa11y.js:445:9)
    at loadRunnerScript (/Users/jose.bolos/.nvm/versions/node/v12.18.3/lib/node_modules/pa11y/lib/pa11y.js:474:23)
    at injectRunners (/Users/jose.bolos/.nvm/versions/node/v12.18.3/lib/node_modules/pa11y/lib/pa11y.js:330:39)
    at runPa11yTest (/Users/jose.bolos/.nvm/versions/node/v12.18.3/lib/node_modules/pa11y/lib/pa11y.js:124:8)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async pa11y (/Users/jose.bolos/.nvm/versions/node/v12.18.3/lib/node_modules/pa11y/lib/pa11y.js:39:18)

Expected behaviour

Pa11y should validate all arguments and return a helpful error message if the arguments are invalid before attempting to do anything else.

Actual behaviour

Crash + stack.

Steps to reproduce

  1. Install pa11y 6 alpha: npm install pa11y@next
  2. Run pa11y --runner potato https://www.nature.com

Environment

  System:
    OS: macOS 10.15.4
    CPU: (8) x64 Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz
    Memory: 384.65 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.18.3 - ~/.nvm/versions/node/v12.18.3/bin/node
    npm: 6.14.6 - ~/.nvm/versions/node/v12.18.3/bin/npm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants