Skip to content

Commit

Permalink
Pass variables to amp/parallel callback
Browse files Browse the repository at this point in the history
  • Loading branch information
veewee committed Jan 12, 2021
1 parent 11ff477 commit 778fad6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
11 changes: 11 additions & 0 deletions doc/parameters.md
Expand Up @@ -90,6 +90,17 @@ A list of the supported variables:

These environment variables can be overwritten by the `environment` settings inside your `grumphp.yml`.

The added environment variables will also be presented to the tasks that GrumPHP executes.
Note that `symfony/process` only passes string values.
If you want to use integers, you need do wrap the value in quotes:

```yaml
grumphp:
environment:
variables:
PHP_CS_FIXER_IGNORE_ENV: "1"
```

**stop_on_failure**

*Default: false*
Expand Down
Expand Up @@ -48,6 +48,8 @@ public function handle(TaskInterface $task, TaskRunnerContext $runnerContext, ca
return $next($task, $runnerContext);
}

$currentEnv = $_ENV;

/**
* This method creates a callable that can be used to enqueue to run the task in parallel.
* The result is wrapped in a serializable closure
Expand All @@ -58,9 +60,10 @@ public function handle(TaskInterface $task, TaskRunnerContext $runnerContext, ca
*
* @var callable(): Promise<TaskResultInterface> $enqueueParallelTask
*/
$enqueueParallelTask = function () use ($task, $runnerContext, $next): Promise {
$enqueueParallelTask = function () use ($task, $runnerContext, $next, $currentEnv): Promise {
return parallel(
static function () use ($task, $runnerContext, $next): SerializableClosure {
static function (array $parentEnv) use ($task, $runnerContext, $next): SerializableClosure {
$_ENV = array_merge($parentEnv, $_ENV);
/** @var TaskResultInterface $result */
$result = wait($next($task, $runnerContext));

Expand All @@ -74,7 +77,7 @@ static function () use ($result) {
);
},
$this->poolFactory->create()
)();
)($currentEnv);
};

return call(
Expand Down

0 comments on commit 778fad6

Please sign in to comment.