@@ -154,17 +154,33 @@ protected function generateModule()
154154 $ this ->files ->makeDirectory (module_path ());
155155 }
156156
157+ $ pathMap = config ('modules.pathMap ' );
157158 $ directory = module_path (null , $ this ->container ['basename ' ]);
158159 $ source = __DIR__ .'/../../../resources/stubs/module ' ;
159160
160161 $ this ->files ->makeDirectory ($ directory );
161- $ this ->files ->copyDirectory ($ source , $ directory , null );
162162
163- $ files = $ this ->files ->allFiles ($ directory );
163+ $ sourceFiles = $ this ->files ->allFiles ($ source , true );
164164
165- foreach ($ files as $ file ) {
165+ if (!empty ($ pathMap )) {
166+ $ search = array_keys ($ pathMap );
167+ $ replace = array_values ($ pathMap );
168+ }
169+
170+ foreach ($ sourceFiles as $ file ) {
166171 $ contents = $ this ->replacePlaceholders ($ file ->getContents ());
167- $ filePath = module_path (null , $ this ->container ['basename ' ].'/ ' .$ file ->getRelativePathname ());
172+ $ subPath = $ file ->getRelativePathname ();
173+
174+ if (!empty ($ pathMap )) {
175+ $ subPath = str_replace ($ search , $ replace , $ subPath );
176+ }
177+
178+ $ filePath = $ directory . '/ ' . $ subPath ;
179+ $ dir = dirname ($ filePath );
180+
181+ if (!$ this ->files ->isDirectory ($ dir )) {
182+ $ this ->files ->makeDirectory ($ dir , 0755 , true );
183+ }
168184
169185 $ this ->files ->put ($ filePath , $ contents );
170186 }
0 commit comments