Skip to content

[Asset] Ignore missing manifest.json files in non-strict mode #46689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ public function testStrictExceptionWhenKeyDoesNotExistInManifest(JsonManifestVer
/**
* @dataProvider provideMissingStrategies
*/
public function testMissingManifestFileThrowsException(JsonManifestVersionStrategy $strategy)
public function testMissingManifestFileThrowsException(JsonManifestVersionStrategy $strategy, bool $isLocal)
{
$this->expectException(RuntimeException::class);
$strategy->getVersion('main.js');
if (!$isLocal) {
$this->expectException(RuntimeException::class);
}
$this->assertSame('main.js', $strategy->getVersion('main.js'));
}

/**
Expand Down Expand Up @@ -109,9 +111,9 @@ public function provideStrategies(string $manifestPath)
return new MockResponse('{}', ['http_code' => 404]);
});

yield [new JsonManifestVersionStrategy('https://cdn.example.com/'.$manifestPath, $httpClient)];
yield [new JsonManifestVersionStrategy('https://cdn.example.com/'.$manifestPath, $httpClient), false];

yield [new JsonManifestVersionStrategy(__DIR__.'/../fixtures/'.$manifestPath)];
yield [new JsonManifestVersionStrategy(__DIR__.'/../fixtures/'.$manifestPath), true];
}

public function provideStrictStrategies()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ private function getManifestPath(string $path): ?string
}
} else {
if (!is_file($this->manifestPath)) {
if (!$this->strictMode) {
return null;
}
throw new RuntimeException(sprintf('Asset manifest file "%s" does not exist. Did you forget to build the assets with npm or yarn?', $this->manifestPath));
}

Expand Down