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

perf: avoid running irrelevant plugins in 'clean' command #4386

Merged
merged 1 commit into from
Jul 2, 2020

Conversation

curbengh
Copy link
Contributor

@curbengh curbengh commented Jun 28, 2020

What does it do?

Loading config and plugins are not needed in hexo clean. Noticed from #4381.
Only filter plugins are executed, i.e. to execute after_clean filter,

How to test

git clone -b BRANCH https://github.com/USER/hexo.git
cd hexo
npm install
npm test

Screenshots

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

@coveralls
Copy link

coveralls commented Jun 28, 2020

Coverage Status

Coverage remained the same at 97.748% when pulling 33dcc90 on curbengh:console-clean into 65961d3 on hexojs:master.

@curbengh curbengh changed the title perf: avoid running plugins in 'clean' command perf: avoid running irrelevant plugins in 'clean' command Jun 28, 2020
@@ -212,6 +212,16 @@ class Hexo extends EventEmitter {
}

init() {
// Load only the relevant plugins in hexo clean
if (this.env.cmd === 'clean') {
Copy link
Contributor Author

@curbengh curbengh Jun 30, 2020

Choose a reason for hiding this comment

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

Initial draft used cmd.startsWith('c'), however in light of #4388, it must now match 'clean'.

#4388 (i.e. alias[this.env.cmd] === 'clean') could not be used here because console plugins (consequently their command aliases) have not been registered at this point.

This means using alias like hexo c cannot benefit from this shortcut. To retain hexo c alias (and avoiding breaking change), clean console plugin is still registered in "plugins/console.js".

@curbengh curbengh marked this pull request as ready for review June 30, 2020 01:06
@curbengh curbengh merged commit 6f87ce9 into hexojs:master Jul 2, 2020
@curbengh curbengh deleted the console-clean branch July 2, 2020 01:14
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.

3 participants