Skip to content

Commit 535da04

Browse files
committed
Merge branch 'release/1.5.3'
2 parents ae7358e + a2798b5 commit 535da04

File tree

3 files changed

+43
-14
lines changed

3 files changed

+43
-14
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# v1.5.3
2+
## 06/16/2021
3+
4+
1. [](#bugfix)
5+
* Fixes over-zealous regex that caused duplication in copy tasks [#69](https://github.com/getgrav/grav-plugin-devtools/issues/69)
6+
17
# v1.5.2
28
## 05/19/2021
39

blueprints.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: DevTools
22
slug: devtools
33
type: plugin
4-
version: 1.5.2
4+
version: 1.5.3
55
description: Plugin and Theme scaffolding utilities
66
icon: cogs
77
author:

classes/DevToolsCommand.php

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -159,20 +159,43 @@ protected function createComponent(): bool
159159
@rename( $base_old_filename . '.php', $base_new_filename . '.php');
160160
@rename( $base_old_filename . '.yaml', $base_new_filename . '.yaml');
161161

162-
$regex_array = [
163-
$new_theme . '.php' => [
164-
['/class ' . $this->inflector::camelize($current_theme) . ' extends/i'],
165-
['class ' . $this->inflector::camelize($name) . ' extends']
166-
],
167-
'blueprints.yaml' => [
168-
['/'.$this->inflector::camelize($current_theme).'/', '/'.$this->inflector::hyphenize($current_theme).'/', '/'.$this->inflector::titleize($current_theme).'/', '/'.$this->inflector::underscorize($current_theme).'/'],
169-
[$this->inflector::camelize($name), $this->inflector::hyphenize($name),$this->inflector::titleize($name), $this->inflector::underscorize($name)]
170-
],
171-
'README.md' => [
172-
['/'.$this->inflector::camelize($current_theme).'/', '/'.$this->inflector::hyphenize($current_theme).'/', '/'.$this->inflector::titleize($current_theme).'/', '/'.$this->inflector::underscorize($current_theme).'/'],
173-
[$this->inflector::camelize($name), $this->inflector::hyphenize($name),$this->inflector::titleize($name), $this->inflector::underscorize($name)]
174-
]
162+
$camelized_current = $this->inflector::camelize($current_theme);
163+
$camelized_new = $this->inflector::camelize($name);
164+
165+
$hyphenized_current = $this->inflector::hyphenize($current_theme);
166+
$hyphenized_new = $this->inflector::hyphenize($name);
167+
168+
$titleized_current = $this->inflector::titleize($current_theme);
169+
$titleized_new = $this->inflector::titleize($name);
170+
171+
$underscoreized_current = $this->inflector::underscorize($current_theme);
172+
$underscoreized_new = $this->inflector::underscorize($name);
173+
174+
$variations_regex = [
175+
["/$camelized_current/", "/$hyphenized_current/"],
176+
[$camelized_new, $hyphenized_new]
177+
];
175178

179+
if (!in_array("/$titleized_current/", array_values($variations_regex[0]))) {
180+
$current_regex = $variations_regex[0];
181+
$new_regex = $variations_regex[1];
182+
$current_regex[] = "/$titleized_current/";
183+
$new_regex[] = $titleized_new;
184+
$variations_regex = [$current_regex, $new_regex];
185+
}
186+
187+
if (!in_array("/$underscoreized_current/", array_values($variations_regex[0]))) {
188+
$current_regex = $variations_regex[0];
189+
$new_regex = $variations_regex[1];
190+
$current_regex[] = "/$underscoreized_current/";
191+
$new_regex[] = $underscoreized_new;
192+
$variations_regex = [$current_regex, $new_regex];
193+
}
194+
195+
$regex_array = [
196+
$new_theme . '.php' => $variations_regex,
197+
'blueprints.yaml' => $variations_regex,
198+
'README.md' => $variations_regex,
176199
];
177200

178201
foreach ($regex_array as $filename => $data) {

0 commit comments

Comments
 (0)