Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
Fixed issue where inline files where not being detected as changed (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickl88 authored and nicoschoenmaker committed Jan 29, 2018
1 parent 8b1726d commit e6885d4
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Bundler/Pipeline/ContentPipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ private function checkIfChanged(File $output_file, DependencyNodeInterface $depe
$files = [];

// Collect all inline dependencies, since if any of those changed we need to recompile.
$walker = new TreeWalker(function (DependencyNodeInterface $d) use (&$files) {
if (!$d->isInlineDependency()) {
$walker = new TreeWalker(function (DependencyNodeInterface $d) use ($dependency, &$files) {
if ($d !== $dependency && !$d->isInlineDependency()) {
return false;
}

Expand Down
49 changes: 49 additions & 0 deletions test/Bundler/Pipeline/ContentPipelineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Hostnet\Component\Resolver\Import\RootFile;
use Hostnet\Component\Resolver\Module;
use Hostnet\Component\Resolver\Report\NullReporter;
use Hostnet\Component\Resolver\Report\ReporterInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Psr\Log\NullLogger;
Expand Down Expand Up @@ -156,6 +157,54 @@ public function testPushDevAlreadyUpToDate()
);
}

public function testPushDevInlineChanged()
{
$reporter = new class implements ReporterInterface
{
public $files;

public function reportOutputFile(File $file): void
{
}
public function reportFileDependencies(File $file, array $dependencies): void
{
}
public function reportFileState(File $file, string $state): void
{
$this->files[$file->path] = $state;
}
public function reportFileContent(File $file, string $content): void
{
}
};

$this->config->isDev()->willReturn(true);
$this->config->getSourceRoot()->willReturn('fixtures');
$this->config->getCacheDir()->willReturn(__DIR__ . '/cache/new');
$this->config->getReporter()->willReturn($reporter);

$input_file = new RootFile(new Module('fixtures/bar.foo', 'fixtures/bar.foo'));
$target_file = new File('fixtures/output.foo');
$reader = new FileReader(__DIR__);

$file = tempnam(__DIR__, 'asset');

try {
$input_file->addChild($dep = new Dependency(new File($file), true));

$this->content_pipeline->addProcessor(new IdentityProcessor('foo'));
$output = $this->content_pipeline->push([$input_file, $dep], $reader, $target_file);

self::assertEquals("foobar\n", $output);
self::assertEquals([
'fixtures/bar.foo' => ReporterInterface::STATE_BUILT,
$file => ReporterInterface::STATE_INLINE,
], $reporter->files);
} finally {
unlink($file);
}
}

/**
* @expectedException \LogicException
* @expectedExceptionMessage Failed to compile resource "input.js".
Expand Down

0 comments on commit e6885d4

Please sign in to comment.