Skip to content

[CB-INTERNAL] move components-details and repository to promises #1265

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

Merged
merged 2 commits into from
Oct 28, 2021

Conversation

ricardo-devis-agullo
Copy link
Collaborator

Fully move components-details and repository to Promises

@ricardo-devis-agullo ricardo-devis-agullo changed the title move components-details and repository to promises [CB-INTERNAL] move components-details and repository to promises Oct 23, 2021
const dirDetails = await getFromDirectories({
componentsList,
details: jsonDetails
}).catch(err => returnError('components_details_get', err));
Copy link
Collaborator

Choose a reason for hiding this comment

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

returnError will throw and thus refresh will finish on this line in case of error, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

correct, if you throw inside catch its like rethrowing

if (componentName === 'oc-client') {
return callback(null, [
fs.readJsonSync(path.join(__dirname, '../../../package.json')).version
return Promise.all([
Copy link
Collaborator

Choose a reason for hiding this comment

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

why Promise.all and not Promise.resolve?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because it's an array of promises, not a promise of an array.

callback(null, [
fs.readJsonSync(path.join(conf.path, `${componentName}/package.json`))
.version
return Promise.all([
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as above

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because it's an array of promises, not a promise of an array.

@ricardo-devis-agullo ricardo-devis-agullo merged commit e244225 into callback-to-promises Oct 28, 2021
@ricardo-devis-agullo ricardo-devis-agullo deleted the components-details-promise branch October 28, 2021 09:40
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

2 participants