Skip to content

Commit

Permalink
Create block: Ensure $slug is replaced with passed slug (WordPress#66528
Browse files Browse the repository at this point in the history
)

* Add --targetDir flag to allow targeting a directory where to scaffold the plugin/files.

* Not using the targetDir when in --no-plugin mode

* Change the name of the flag to match others and update changelog.

* WIP commit.

* Add logic to generate the paths for the root and block files in one place.

* Add a new parameter to allow passing the path once rather than generating it in the function.

* Modify the other functions to use the generated paths.

* Update the command description.

* Update packages/create-block/CHANGELOG.md

* Refactor the handling for the root directory

* Improve the documentation for target dir

* Reorder CLI options in the docs

* Ensure that $slug is replaced.

---------

Co-authored-by: Greg Ziółkowski <[email protected]>

Co-authored-by: ryanwelcher <[email protected]>
Co-authored-by: gziolo <[email protected]>
Co-authored-by: t-hamano <[email protected]>
  • Loading branch information
4 people authored Oct 29, 2024
1 parent f760da0 commit 90fbc53
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/create-block/lib/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ const writeOutputTemplate = async ( inputFile, outputFile, view ) => {
if ( renderedFile.trim().length ) {
const outputFilePath = join( view.rootDirectory, outputFile );
await makeDir( dirname( outputFilePath ) );
writeFile( outputFilePath, renderedFile );
writeFile(
outputFilePath.replace( /\$slug/g, view.slug ),
renderedFile
);
}
};

Expand Down

0 comments on commit 90fbc53

Please sign in to comment.