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: initial implementation of processorAsync #205

Merged
merged 4 commits into from
Dec 17, 2024

Conversation

johnnyreilly
Copy link
Contributor

@johnnyreilly johnnyreilly commented Dec 14, 2024

This PR is a basic implementation of the Async custom processors proposal: #204

As discussed on the linked issue the API is:

const results = await replaceInFile({
  files: 'path/to/files/*.html',
  processorAsync: async (input, file) => { 
    const asyncResult = await doAsyncOperation(input, file);
    return input.replace(/foo/g, asyncResult) 
  },
})

What do you think? Is this what you had in mind?

Copy link
Owner

@adamreisnz adamreisnz left a comment

Choose a reason for hiding this comment

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

Thanks, looks good! Just keen to get the one error case tested as well so we retain good coverage of the code.

src/replace-in-file.js Outdated Show resolved Hide resolved
Copy link
Owner

@adamreisnz adamreisnz left a comment

Choose a reason for hiding this comment

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

Thank you!

@adamreisnz adamreisnz merged commit 4ae6ac9 into adamreisnz:main Dec 17, 2024
@adamreisnz
Copy link
Owner

Released in 8.3.0

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