Skip to content

Commit

Permalink
fix(commands): use Array#some instead of Array#includes for type-safety
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainLanz committed Nov 25, 2024
1 parent 8696178 commit c598b55
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ export default class Add extends BaseCommand {
* Detect the package manager to use
*/
async #getPackageManager() {
const pkgManager =
const packageManager =
this.packageManager || (await detectPackageManager(this.app.makePath())) || 'npm'

if (KNOWN_PACKAGE_MANAGERS.includes(pkgManager)) {
return pkgManager
if (
KNOWN_PACKAGE_MANAGERS.some((knownPackageManager) => knownPackageManager === packageManager)
) {
return packageManager as (typeof KNOWN_PACKAGE_MANAGERS)[number] | undefined
}

throw new Error('Invalid package manager. Must be one of npm, pnpm, bun or yarn')
Expand Down

0 comments on commit c598b55

Please sign in to comment.