-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_gulp_to_subtheme.patch
64 lines (62 loc) · 2.24 KB
/
add_gulp_to_subtheme.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
diff --git a/bootstrap.drush.inc b/bootstrap.drush.inc
index 22d1f0b..2c6eb27 100644
--- a/bootstrap.drush.inc
+++ b/bootstrap.drush.inc
@@ -183,7 +183,14 @@ function drush_bootstrap_sub_theme($name = NULL, $machine_name = NULL, $descript
));
drush_pm_enable_validate($machine_name);
drush_pm_enable($machine_name);
-
+ $src = $getstudio_path . '/' . "gulp";
+ $dest = $subtheme_path;
+ bootstrap_drush_copy_dir($src, $dest, $overwrite = FILE_EXISTS_MERGE);
+ drush_print(dt("\n!name Bootstrap Sass sub-theme was successfully created! \n",
+ array(
+ '!name' => $name,
+ )
+ ));
}
/**
@@ -195,6 +202,35 @@ function bootstrap_file_str_replace($file_path, $find, $replace) {
file_put_contents($file_path, $file_contents);
}
+function bootstrap_drush_copy_dir($src, $dest, $overwrite = FILE_EXISTS_ABORT) {
+ if (file_exists($dest)) {
+ if ($overwrite === FILE_EXISTS_OVERWRITE) {
+ drush_op('drush_delete_dir', $dest, TRUE);
+ }
+ elseif ($overwrite === FILE_EXISTS_ABORT) {
+ return drush_set_error('DRUSH_DESTINATION_EXISTS', dt('Destination directory !dest already exists.', array('!dest' => $dest)));
+ }
+ elseif ($overwrite === FILE_EXISTS_MERGE) {
+ // $overwrite flag may indicate we should merge instead.
+ drush_log(dt('Merging existing !dest directory', array('!dest' => $dest)));
+ }
+ }
+ // $src readable?
+ if (!is_readable($src)) {
+ return drush_set_error('DRUSH_SOURCE_NOT_EXISTS', dt('Source directory !src is not readable or does not exist.', array('!src' => $src)));
+ }
+ // $dest writable?
+ if (!is_writable(dirname($dest))) {
+ return drush_set_error('DRUSH_DESTINATION_NOT_WRITABLE', dt('Destination directory !dest is not writable.', array('!dest' => dirname($dest))));
+ }
+ // Try to do a recursive copy.
+ if (@drush_op('_drush_recursive_copy', $src, $dest)) {
+ return TRUE;
+ }
+
+ return drush_set_error('DRUSH_COPY_DIR_FAILURE', dt('Unable to copy !src to !dest.', array('!src' => $src, '!dest' => $dest)));
+ }
+
/**
* Implements hook_drush_help().
*/
@@ -203,4 +239,5 @@ function bootstrap_drush_help($section) {
case 'drush:bootstrap-sub-theme':
return dt("Create a Boostrap custom sub-theme.");
}
-}
\ No newline at end of file
+}
+