Skip to content

Commit 439b08f

Browse files
committed
Prevent overwrite files
1 parent f16180c commit 439b08f

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

src/Providers/AcfComposerServiceProvider.php

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -90,28 +90,37 @@ public function create_acf_settings() {
9090

9191
public function create_section_component() {
9292

93-
\FileManager::copy_file(
94-
__DIR__ . '/../../src/Console/components/section.blade.php',
95-
$this->app->resourcePath('views/components/'),
96-
'section.blade.php'
97-
);
93+
if ( ! file_exists( $this->app->resourcePath('views/components/section.blade.php') ) ) {
94+
\FileManager::copy_file(
95+
__DIR__ . '/../../src/Console/components/section.blade.php',
96+
$this->app->resourcePath('views/components/'),
97+
'section.blade.php'
98+
);
99+
}
98100

99-
\FileManager::copy_file(
100-
__DIR__ . '/../../src/Console/components/Section.php',
101-
$this->app->basePath('app/View/Components/'),
102-
'Section.php'
103-
);
101+
if ( ! file_exists( $this->app->basePath('app/View/Components/Section.php') ) ) {
102+
\FileManager::copy_file(
103+
__DIR__ . '/../../src/Console/components/Section.php',
104+
$this->app->basePath('app/View/Components/'),
105+
'Section.php'
106+
);
107+
}
104108

105109
}
106110
public function create_global_settings() {
107-
$dir = $this->app->basePath('app/Options');
108-
exec("mkdir {$dir}");
109111

110-
\FileManager::copy_file(
111-
__DIR__ . '/../../src/Console/Options/GlobalSettings.php',
112-
$this->app->basePath('app/Options/'),
113-
'GlobalSettings.php'
114-
);
112+
if ( ! is_dir( $dir = $this->app->basePath('app/Options') ) ) {
113+
$dir = $this->app->basePath('app/Options');
114+
exec("mkdir {$dir}");
115+
}
116+
117+
if ( ! file_exists( $this->app->basePath('app/Options/GlobalSettings.php') ) ) {
118+
\FileManager::copy_file(
119+
__DIR__ . '/../../src/Console/Options/GlobalSettings.php',
120+
$this->app->basePath('app/Options/'),
121+
'GlobalSettings.php'
122+
);
123+
}
115124

116125
}
117126
}

0 commit comments

Comments
 (0)