From 9290dc111c552ffb6db5296e80edf6ac45404581 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Mon, 1 Apr 2024 10:39:00 +0545 Subject: [PATCH] Create multilevel folders --- src/Scaffold_Command.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Scaffold_Command.php b/src/Scaffold_Command.php index 023ddb9f..c418a011 100644 --- a/src/Scaffold_Command.php +++ b/src/Scaffold_Command.php @@ -607,7 +607,6 @@ private function get_output_path( $assoc_args, $subdir ) { * default: circle * options: * - circle - * - bitbucket * - gitlab * - github * --- @@ -955,6 +954,12 @@ protected function create_files( $files_and_contents, $force ) { $wp_filesystem->mkdir( dirname( $filename ) ); + // Create multi-level folders. + if ( false === $wp_filesystem->exists( dirname( $filename ) ) ) { + $wp_filesystem->mkdir( dirname( dirname( $filename ) ) ); + $wp_filesystem->mkdir( dirname( $filename ) ); + } + if ( ! $wp_filesystem->put_contents( $filename, $contents ) ) { WP_CLI::error( "Error creating file: {$filename}" ); } elseif ( $should_write_file ) {