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

callback in code usage is not work #288

Closed
huruji opened this issue Dec 21, 2018 · 4 comments
Closed

callback in code usage is not work #288

huruji opened this issue Dec 21, 2018 · 4 comments

Comments

@huruji
Copy link
Contributor

huruji commented Dec 21, 2018

I use standard-version in my project, but I found the callback in code usage is not work

my code:

standardVersion({
    }, function(err) {
        console.log('callback')
        if (err) {
            process.chdir(root);
            process.exit()
        }
})

output when standard-version is success
image

output when standard-version is failed

image

And I made a breakpoint in my code , but it still not work , I have no idea now. Give me a hand, please

image

@nexdrew
Copy link
Member

nexdrew commented Dec 21, 2018

The function exported by the main module (index.js) no longer accepts a callback as a 2nd argument - instead it returns a Promise.

This is a breaking change that was introduced between version 4.0.0 and 4.1.0 - meaning the 4.1.0 release should have been 5.0.0. 😞

It also appears the Code usage portion of the README has not been updated to reflect this change either. 😿

So, apologies, it looks like we goofed up here.

In the meantime, try changing your code to something like this instead:

standardVersion()
  .then(_ => console.log('success'))
  .catch(err => {
    process.chdir(root)
    process.exit(1)
  })

@huruji
Copy link
Contributor Author

huruji commented Dec 21, 2018

Oh, It works. 👍 very thank you!

Returns a Promise is better than using callback, We then need update the docs, can I make a PR to update it? standard-version is a great project, thank you again! 🎉

@stevemao
Copy link
Member

@huruji Yes please!

@huruji
Copy link
Contributor Author

huruji commented Dec 24, 2018

ok, I will @stevemao

@huruji huruji closed this as completed Dec 24, 2018
stevemao pushed a commit that referenced this issue Dec 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants