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

onProgress option added #52

Merged
merged 8 commits into from
Jun 21, 2022
Merged

onProgress option added #52

merged 8 commits into from
Jun 21, 2022

Conversation

fitiskin
Copy link
Contributor

@fitiskin fitiskin commented Apr 25, 2022

Fixes #51

  • .on() has been deprecated
  • added onProgress option (async mode only)

@fitiskin
Copy link
Contributor Author

I don't know how to correctly reflect the changes for readme.md.

index.d.ts Outdated Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
index.d.ts Show resolved Hide resolved
test/progress.js Outdated Show resolved Hide resolved
index.js Outdated
@@ -65,6 +65,10 @@ const cpFile = (sourcePath, destinationPath, options) => {
const progressEmitter = new ProgressEmitter(path.resolve(sourcePath), path.resolve(destinationPath));
const promise = cpFileAsync(sourcePath, destinationPath, options, progressEmitter);

if (typeof options.onProgress === 'function') {
progressEmitter.on('progress', options.onProgress);
Copy link
Owner

Choose a reason for hiding this comment

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

It should be the inverse. .on should use onProgress. This would make it easier to remove the deprecated .on method in a future release.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry I don't understand. How can promise.on use options.onProgress?

Copy link
Owner

Choose a reason for hiding this comment

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

Pretend that promise.on and progressEmitter doesn't exist and try to implement options.onProgress. That what the implementation should be.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It makes sense but promise.on handles it on a different phase (chained). I can try to rewrite it this week.

Copy link
Contributor Author

@fitiskin fitiskin Jun 17, 2022

Choose a reason for hiding this comment

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

I've found a way to cover deprecated implementation through options mutation but I am not sure about that.

readme.md Outdated Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
@sindresorhus
Copy link
Owner

Can you fix the merge conflict?

fitiskin and others added 2 commits May 9, 2022 12:43
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
@sindresorhus
Copy link
Owner

Friendly bump :)

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.

Use onProgress option instead of event for progress reporting
3 participants