Skip to content

Commit 458d7b6

Browse files
committed
Rename fail() to onfail()
1 parent b1f33b1 commit 458d7b6

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

docs/api.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* [`task()`](#task)
1515
* [`before()`](#before)
1616
* [`after()`](#after)
17-
* [`fail()`](#fail)
17+
* [`onfail()`](#onfail)
1818
* [`option()`](#option)
1919
* [`cd()`](#cd)
2020
* [`within()`](#within)
@@ -184,14 +184,14 @@ Call that task after specified task runs.
184184

185185
The task to be run.
186186

187-
## fail()
187+
## onfail()
188188

189189
```php
190-
fail(string $task, $do)
190+
onfail(string $task, $do)
191191
```
192192

193193
Setup which task run on failure of $task.
194-
When called multiple times for a task, previous fail() definitions will be overridden.
194+
When called multiple times for a task, previous onfail() definitions will be overridden.
195195

196196

197197

recipe/common.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
task('deploy:failed', function () {
185185
})->hidden();
186186

187-
fail('deploy', 'deploy:failed');
187+
onfail('deploy', 'deploy:failed');
188188

189189
/**
190190
* Follow latest application logs.

src/Command/MainCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ protected function execute(Input $input, Output $output): int
131131
}
132132

133133
// Check if we have tasks to execute on failure.
134-
if ($this->deployer['fail']->has($this->getName())) {
135-
$taskName = $this->deployer['fail']->get($this->getName());
134+
if ($this->deployer['onfail']->has($this->getName())) {
135+
$taskName = $this->deployer['onfail']->get($this->getName());
136136
$tasks = $this->deployer->scriptManager->getTasks($taskName);
137137
$this->deployer->master->run($tasks, $hosts);
138138
}

src/Deployer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
* @property Messenger $messenger
7070
* @property Messenger $logger
7171
* @property Printer $pop
72-
* @property Collection $fail
72+
* @property Collection $onfail
7373
* @property InputDefinition $inputDefinition
7474
* @property Importer $importer
7575
*/
@@ -150,7 +150,7 @@ public function __construct(Application $console)
150150
$this['selector'] = function ($c) {
151151
return new Selector($c['hosts']);
152152
};
153-
$this['fail'] = function () {
153+
$this['onfail'] = function () {
154154
return new Collection();
155155
};
156156
$this['messenger'] = function ($c) {

src/Exception/GracefulShutdownException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
namespace Deployer\Exception;
99

1010
/**
11-
* Then this exception thrown, it will not trigger "fail" callback.
11+
* Then this exception thrown, it will not trigger "onfail" callback.
1212
*
13-
* fail('deploy', 'deploy:failed');
13+
* onfail('deploy', 'deploy:failed');
1414
*
1515
* task('deploy', function () {
1616
* throw new GracefulShutdownException(...);

src/functions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,22 +230,22 @@ function after(string $task, $do)
230230

231231
/**
232232
* Setup which task run on failure of $task.
233-
* When called multiple times for a task, previous fail() definitions will be overridden.
233+
* When called multiple times for a task, previous onfail() definitions will be overridden.
234234
*
235235
* @param string $task The task which need to fail so $that should be run.
236236
* @param string|callable $do The task to be run.
237237
*
238238
* @return Task|null
239239
*/
240-
function fail(string $task, $do)
240+
function onfail(string $task, $do)
241241
{
242242
if (is_callable($do)) {
243243
$newTask = task("fail:$task", $do);
244-
fail($task, "fail:$task");
244+
onfail($task, "fail:$task");
245245
return $newTask;
246246
}
247247
$deployer = Deployer::get();
248-
$deployer->fail->set($task, $do);
248+
$deployer->onfail->set($task, $do);
249249

250250
return null;
251251
}

tests/joy/recipe/deploy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@
4444
run('false');
4545
});
4646

47-
fail('deploy:fail', 'deploy:unlock');
47+
onfail('deploy:fail', 'deploy:unlock');

0 commit comments

Comments
 (0)