antfu-collective / local-pkg

Get information on local packages.
MIT License
154 stars 16 forks source link

feat: `isPackageExists` support version check #12

Closed chizukicn closed 1 year ago

chizukicn commented 1 year ago

Description

This PR will add version checking support for semver rules to isPackageExists. So that we can use it to achieve something like

const isVue2 = isPackageExists("vue", {
  version: ">2 || <3"
});

export default {
  extends: [
    isVue2
      ? "plugin:vue/recommended"
      : "plugin:vue/vue3-recommended",
  ]
}

Linked Issues

Additional context

antfu commented 1 year ago

Thanks, but no, it's beyond the scope of this package, and I don't want to introduce semver as a dep when it's not a core feature.