public function compile(string $path) : Awaitable { return new Coroutine(function () use($path) { $args = [$path, $this->locator->getPaths(), $this->minify ? Crunched::class : Expanded::class, $this->lineComments]; list($css, $info) = (yield LoopConfig::currentPool()->invokeStaticMethod(static::class, 'compileFile', ...$args)); $files = []; foreach ($info as $file => $mtime) { $files[\str_replace('\\', '/', $file)] = $mtime; } if ($this->logger) { $data = ''; foreach (\array_keys($files) as $file) { $data .= "\n" . $file; } $this->logger->debug("Compiled SCSS file <{file}> from sources:" . $data, ['file' => \basename($path)]); } return [$css, $files]; }); }
protected function observeFilesystem() : \Generator { $state = (yield LoopConfig::currentPool()->invokeStaticMethod(static::class, 'scanFilesystem', $this->files, $this->dirs)); while (true) { (yield new Pause(1)); $hash = (yield LoopConfig::currentPool()->invokeStaticMethod(static::class, 'scanFilesystem', $this->files, $this->dirs)); if ($hash !== $state) { $state = $hash; $this->logger->info('Restarting due to changes in observed files / dirs'); yield from $this->restart(); } } }
public function syncFiles() : Awaitable { return new Coroutine(function () { $this->watchedResources = (yield LoopConfig::currentPool()->invokeStaticMethod(static::class, 'collectAppResources', $this->paths['app'])); }); }