@@ -120,9 +120,9 @@ function formatSizeUnits($bytes)
120120 return $ bytes ;
121121 }
122122}
123- if (! function_exists ('genarateFileIndex ' )) {
123+ if ( ! function_exists ('generateFileIndex ' )) {
124124 /**
125- * Function genarateFileIndex
125+ * Function generateFileIndex
126126 *
127127 * @param string $file_path
128128 * @param string $file_name
@@ -132,7 +132,7 @@ function formatSizeUnits($bytes)
132132 * @copyright: 713uk13m <dev@nguyenanhung.com>
133133 * @time : 09/11/2021 55:13
134134 */
135- function genarateFileIndex ($ file_path = '' , $ file_name = 'index.html ' )
135+ function generateFileIndex ($ file_path = '' , $ file_name = 'index.html ' )
136136 {
137137 if (function_exists ('log_message ' ) && function_exists ('write_file ' )) {
138138 if ($ file_path !== '' ) {
@@ -164,9 +164,9 @@ function genarateFileIndex($file_path = '', $file_name = 'index.html')
164164 return false ;
165165 }
166166}
167- if (! function_exists ('genarateFileHtaccess ' )) {
167+ if ( ! function_exists ('generateFileHtaccess ' )) {
168168 /**
169- * Function genarateFileHtaccess
169+ * Function generateFileHtaccess
170170 *
171171 * @param string $file_path
172172 * @param string $file_name
@@ -176,7 +176,7 @@ function genarateFileIndex($file_path = '', $file_name = 'index.html')
176176 * @copyright: 713uk13m <dev@nguyenanhung.com>
177177 * @time : 09/11/2021 55:51
178178 */
179- function genarateFileHtaccess ($ file_path = '' , $ file_name = '.htaccess ' )
179+ function generateFileHtaccess ($ file_path = '' , $ file_name = '.htaccess ' )
180180 {
181181 if (function_exists ('log_message ' ) && function_exists ('write_file ' )) {
182182 if ($ file_path !== '' ) {
@@ -208,7 +208,7 @@ function genarateFileHtaccess($file_path = '', $file_name = '.htaccess')
208208 return false ;
209209 }
210210}
211- if (! function_exists ('genarateFileReadme ' )) {
211+ if ( ! function_exists ('generateFileReadme ' )) {
212212 /**
213213 * Function genarateFileReadme
214214 *
@@ -220,7 +220,7 @@ function genarateFileHtaccess($file_path = '', $file_name = '.htaccess')
220220 * @copyright: 713uk13m <dev@nguyenanhung.com>
221221 * @time : 09/15/2021 58:14
222222 */
223- function genarateFileReadme ($ file_path = '' , $ file_name = 'README.md ' )
223+ function generateFileReadme ($ file_path = '' , $ file_name = 'README.md ' )
224224 {
225225 if (function_exists ('log_message ' ) && function_exists ('write_file ' )) {
226226 if ($ file_path !== '' ) {
@@ -256,13 +256,14 @@ function genarateFileReadme($file_path = '', $file_name = 'README.md')
256256 * Function makeNewFolder
257257 *
258258 * @param string $folderPath
259+ * @param bool $gitkeep
259260 *
260261 * @return bool
261262 * @author : 713uk13m <dev@nguyenanhung.com>
262263 * @copyright: 713uk13m <dev@nguyenanhung.com>
263264 * @time : 09/11/2021 57:33
264265 */
265- function makeNewFolder ($ folderPath = '' )
266+ function makeNewFolder ($ folderPath = '' , $ gitkeep = false )
266267 {
267268 if (empty ($ folderPath )) {
268269 return false ;
@@ -271,10 +272,26 @@ function makeNewFolder($folderPath = '')
271272 if (!mkdir ($ folderPath ) && !is_dir ($ folderPath )) {
272273 throw new RuntimeException (sprintf ('Directory "%s" was not created ' , $ folderPath ));
273274 }
274- genarateFileIndex ($ folderPath );
275- genarateFileHtaccess ($ folderPath );
276- genarateFileReadme ($ folderPath );
277-
275+ $ createIndex = generateFileIndex ($ folderPath );
276+ $ createHtaccess = generateFileHtaccess ($ folderPath );
277+ $ createReadme = generateFileReadme ($ folderPath );
278+ if (is_cli ()) {
279+ if ($ createIndex ) {
280+ echo "Create file index.html in " . $ folderPath . " successfully " ;
281+ }
282+ if ($ createHtaccess ) {
283+ echo "Create file .htaccess in " . $ folderPath . " successfully " ;
284+ }
285+ if ($ createReadme ) {
286+ echo "Create file README.md in " . $ folderPath . " successfully " ;
287+ }
288+ }
289+ if ($ gitkeep === true ) {
290+ $ createGitkeep = touch ($ folderPath . '/.gitkeep ' );
291+ if (is_cli () && $ createGitkeep ) {
292+ echo "Create file .gitkeep in " . $ folderPath . " successfully " ;
293+ }
294+ }
278295 return true ;
279296 }
280297
@@ -286,15 +303,16 @@ function makeNewFolder($folderPath = '')
286303 * Function new_folder
287304 *
288305 * @param string $folder
306+ * @param bool $gitkeep
289307 *
290308 * @return bool
291309 * @author : 713uk13m <dev@nguyenanhung.com>
292310 * @copyright: 713uk13m <dev@nguyenanhung.com>
293311 * @time : 09/11/2021 58:13
294312 */
295- function new_folder ($ folder = '' )
313+ function new_folder ($ folder = '' , $ gitkeep = false )
296314 {
297- return makeNewFolder ($ folder );
315+ return makeNewFolder ($ folder, $ gitkeep );
298316 }
299317}
300318if (!function_exists ('scan_folder ' )) {
0 commit comments