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

Allow local directories to be passed to --template as relative paths. #35645

Merged
merged 2 commits into from
Oct 14, 2021

Conversation

ryanwelcher
Copy link
Contributor

@ryanwelcher ryanwelcher commented Oct 14, 2021

Description

Check to see if the item passed to the --template flag is a directory and if so, resolve it to allow it to be loaded.

When checking to see how the current tool handles local templates, I found that I was able to pass an absolute path to a template and it worked fine. This PR takes the approach of checking if the passed value is an actual directory and if so, resolving it to an absolute path. Otherwise, it operates as normal.

How has this been tested?

This was testing running the package locally via node.

Screenshots

Types of changes

New feature.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

@ryanwelcher
Copy link
Contributor Author

Closes #34547

@ryanwelcher ryanwelcher changed the title Allow local directories to be passed to --template Allow local directories to be passed to --template as relative paths. Oct 14, 2021
@gziolo gziolo added [Package] Create Block /packages/create-block [Type] Enhancement A suggestion for improvement. labels Oct 14, 2021
Copy link
Member

@mkaz mkaz left a comment

Choose a reason for hiding this comment

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

This worked well in my testing, and code looks good.

I tested by checking out my richtext-block template.

  1. Updated and built gutenberg based off this PR.
  2. git clone https://github.com/mkaz/mkaz-block-template
  3. Ran script specifying template
    ../node_modules/.bin/wp-create-block --template ./mkaz-block-template

Confirmed the new block created was based off my template.

Good work, thanks for implementing 👍

@ryanwelcher ryanwelcher merged commit 13a6043 into WordPress:trunk Oct 14, 2021
@github-actions github-actions bot added this to the Gutenberg 11.8 milestone Oct 14, 2021
ryanwelcher added a commit to ryanwelcher/gutenberg that referenced this pull request Oct 15, 2021
ryanwelcher added a commit that referenced this pull request Oct 15, 2021
* Update changelog to reflect changes in #35645.

* Remove unneeded word.

* Update readme to inlcude local template references and example.

* Fix indentation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Create Block /packages/create-block [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants