Skip to content

Commit 0ae8fea

Browse files
committed
Support loading scripts from local
1 parent 42f3199 commit 0ae8fea

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/Hook.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,16 @@ public function __construct($data)
2222
{
2323
$this->update($data);
2424

25-
$this->mergeWithJson(base_path("hooks/{$this->name}/hook.json"));
25+
$this->loadJson();
26+
}
27+
28+
public function loadJson($path = null)
29+
{
30+
if (is_null($path)) {
31+
$path = base_path("hooks/{$this->name}/hook.json");
32+
}
33+
34+
$this->mergeWithJson($path);
2635
}
2736

2837
public function update(array $parameters)

src/Hooks.php

+9
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ public function uninstall($name, $keep = false)
129129

130130
$hook = $this->hook($name);
131131

132+
$hook->loadJson();
133+
132134
event(new Events\UninstallingHook($hook));
133135

134136
if ($this->enabled($name)) {
@@ -182,6 +184,8 @@ public function update($name, $version = null)
182184

183185
$hook = $this->hook($name);
184186

187+
$hook->loadJson();
188+
185189
if ($version == $hook->version) {
186190
return false;
187191
}
@@ -234,6 +238,8 @@ public function enable($name)
234238

235239
$hook = $this->hook($name);
236240

241+
$hook->loadJson();
242+
237243
event(new Events\EnablingHook($hook));
238244

239245
$this->runScripts($name, 'enable');
@@ -270,6 +276,8 @@ public function disable($name)
270276

271277
$hook = $this->hook($name);
272278

279+
$hook->loadJson();
280+
273281
event(new Events\DisablingHook($hook));
274282

275283
$this->runScripts($name, 'disable');
@@ -517,6 +525,7 @@ public function runScripts($name, $events)
517525
}
518526

519527
$hook = $this->hook($name);
528+
$hook->loadJson();
520529

521530
foreach ($events as $event) {
522531
foreach ($hook->scripts($event) as $script) {

0 commit comments

Comments
 (0)