Skip to content
New issue

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

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

Already on GitHub? # to your account

npmName.many error #29

Closed
ZYSzys opened this issue Jan 14, 2019 · 1 comment · Fixed by #38
Closed

npmName.many error #29

ZYSzys opened this issue Jan 14, 2019 · 1 comment · Fixed by #38

Comments

@ZYSzys
Copy link

ZYSzys commented Jan 14, 2019

Refs: sindresorhus/npm-name-cli#16

When an error happening, all the others results missed.

const npmName = require('npm-name');

(async () => {
  try {
    await npmName.many(['sdhd','_ABC', 'chalk']);
  } catch (error) {
    console.log(error.message);
    // Invalid package name: _ABC
    // - name cannot start with an underscore
    // - name can no longer contain capital letters
  }
})();

One way I thought to fix it is return error instead of throw error when validating name, and then we check the result(true or false or instanceof Error) in other modules.
@sindresorhus how do you think, is it reasonable for you ?

@sindresorhus
Copy link
Owner

You could use https://github.com/sindresorhus/p-settle instead of Promise.all and then throw an https://github.com/sindresorhus/aggregate-error error if there were any errors. Alternatively, you could add an optional to https://github.com/sindresorhus/p-map to only throw an aggregate error at the end.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
2 participants