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

feat: support detect the range version of packageManager #179

Merged
merged 1 commit into from
Nov 9, 2023

Conversation

Dunqing
Copy link
Contributor

@Dunqing Dunqing commented Oct 18, 2023

Description

Issue from ant-design/ant-design#45327

Corepack has supported a range version for a long time. You can see nodejs/corepack#136

Linked Issues

Additional context

@@ -32,7 +32,7 @@ export async function detect({ autoInstall, programmatic, cwd }: DetectOptions =
try {
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
if (typeof pkg.packageManager === 'string') {
const [name, ver] = pkg.packageManager.split('@')
const [name, ver] = pkg.packageManager.replace(/^\^/, '').split('@')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是不是可以用正则表达式来判断?

const [, name, ver] = packageManager.match(new RegExp(`^(${Object.values(LOCKS).join('|')})@(\\d+\\.\\d+\\.\\d)+(-.+)?`)) || []

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using regexp gets complicated

@antfu antfu merged commit b616eb3 into antfu-collective:main Nov 9, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants