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

refactor: make CLI async #286

Merged
merged 3 commits into from
Mar 4, 2025
Merged

refactor: make CLI async #286

merged 3 commits into from
Mar 4, 2025

Conversation

fisker
Copy link
Collaborator

@fisker fisker commented Jan 30, 2023

This is based on #278, will rebase after #278 merged.

Forgot we still support Node.js v12, we'll have to wait untill we drop it.

function sortPackageJsonFiles(patterns, { ignore, ...options }) {
const files = globSync(patterns, { ignore })
async function sortPackageJsonFiles(patterns, { ignore, ...options }) {
const files = await glob(patterns, { ignore })
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In the original implmention I want to use globStream from globby, but tinyglobby doesn't support.

SuperchupuDev/tinyglobby#24

try {
sortPackageJsonFile(file, reporter, isCheck)
await sortPackageJsonFile(file, reporter, isCheck)
} catch (error) {
reporter.reportFailed(file, error)
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Still running serially, hard to make test pass if switch to parallel, I guess we can revist later.

@fisker fisker marked this pull request as ready for review March 4, 2025 16:44
import sortPackageJson from './index.js'
import Reporter from './reporter.js'
import packageJson from './package.json' with { type: 'json' }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should I move this to showVersion?

@keithamus keithamus merged commit 6e739b2 into keithamus:main Mar 4, 2025
2 checks passed
@fisker fisker deleted the async-cli branch March 4, 2025 16:56
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.

2 participants