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

When promisifying, store does not preserve disableNunjucks property #2670

Merged
merged 4 commits into from Nov 27, 2022

Conversation

tcr
Copy link
Contributor

@tcr tcr commented Jul 27, 2017

This was causing difficulties in a less-maintained renderer I was using, but I think this may also count as a bug upstream.

This was causing difficulties in a less-maintained renderer I was using, but I think this may also count as a bug upstream.
@coveralls
Copy link

coveralls commented Jul 27, 2017

Coverage Status

Coverage increased (+0.003%) to 97.155% when pulling 4966094 on tcr:patch-1 into e2b81fa on hexojs:master.

@JLHwung
Copy link
Collaborator

JLHwung commented Jul 27, 2017

Hmm, I don't think Promise.promisify will discard property of a given nodeFunction. You can check on the Chrome console of http://bluebirdjs.com/docs/getting-started.html.

f = function() {}
f.foo = "bar"
// returns "bar"
Promise.promisify(f).foo 

@tcr
Copy link
Contributor Author

tcr commented Jul 27, 2017

You're correct! It's only Promise.method that doesn't preserve the property.

@coveralls
Copy link

coveralls commented Jul 27, 2017

Coverage Status

Coverage decreased (-0.04%) to 98.706% when pulling 29ab720 on tcr:patch-1 into 58a8f8c on hexojs:master.

@NoahDragon
Copy link
Member

@tcr Is that possible to pass in all the configuration to the sync process? If later on, new configuration needed/added, our goal is to not modify the same piece of code again.

@tcr
Copy link
Contributor Author

tcr commented Jul 27, 2017

@NoahDragon Would that be a proposal that instead of attaching disableNunjucks to the rendering function, it's passed in as an extra argument (or something) to the register method?

One way I can think of is to change sync to check if it's a boolean (former behavior), and if it's an object e.g. {sync: true, disableNunjucks: true} treat it as an options object. Or, just add another argument to the render method to accept an object hash.

The change would impact #2593 in either case—let me know if you think one of these is a good idea. cc @be5invis

@NoahDragon
Copy link
Member

@tcr Sorry for the late reply. I would prefer the old approach, which check sync if it's boolean. We could review later how much impacts to the #2593 change.

@stale stale bot added the stale label Nov 18, 2017
@be5invis
Copy link
Contributor

@NoahDragon
Whether enabling Nunjucks could be a "OR" of multiple sources:

  • Whether user specifies to disable it in the entire site
  • Whether user specifies to disable it in for a specific post
  • Whether the renderer said that it can handle everything on its own

@stale stale bot removed the stale label Nov 18, 2017
@JLHwung
Copy link
Collaborator

JLHwung commented Dec 1, 2017

I raised an issue (petkaantonov/bluebird#1484) to request retaining custom properties on Promise.method. Before the decision is made, hexo is not looking forward to implement it is own copyDescriptors.

@stale
Copy link

stale bot commented Jan 30, 2018

This issue has been automatically marked as stale because lack of recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 30, 2018
@stale stale bot closed this Feb 6, 2018
@github-actions
Copy link

How to test

git clone -b patch-1 https://github.com/tcr/hexo.git
cd hexo
npm install
npm test

@hexojs hexojs deleted a comment from stale bot Nov 26, 2022
stevenjoezhang
stevenjoezhang previously approved these changes Nov 26, 2022
Copy link
Member

@stevenjoezhang stevenjoezhang left a comment

Choose a reason for hiding this comment

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

👍

@stevenjoezhang stevenjoezhang added this to the 7.0.0 milestone Nov 26, 2022
SukkaW
SukkaW previously approved these changes Nov 26, 2022
Copy link
Member

@SukkaW SukkaW left a comment

Choose a reason for hiding this comment

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

Since Bluebird is no longer actively maintained, I guess we can accept this workaround for now.

We could, however, replace Bluebird.method with Bluebird.promisfy in the future.

@stevenjoezhang
Copy link
Member

Found another patch: #4498
We could revert #4498 since the solution in this PR is simpler
See also #3860

@stevenjoezhang stevenjoezhang dismissed stale reviews from SukkaW and themself via 29ab720 November 27, 2022 13:26
@stevenjoezhang stevenjoezhang merged commit 00bcce5 into hexojs:master Nov 27, 2022
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

7 participants