Skip to content

Commit

Permalink
Tweaks in strip-sources-links extension
Browse files Browse the repository at this point in the history
  • Loading branch information
kduma committed Dec 16, 2023
1 parent a5bf30f commit 7e86967
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions app/Extensions/StripSourcesLinksExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,27 @@ public function hook(BuildStateInterface $buildState): void
->mapWithKeys(function ($parameters, $path) use ($buildState) {
$this->processIncludesFile(str($path), $buildState);

if ($parameters->has('sha1')) {
$old_sha1 = $parameters->get('sha1');
if (!$parameters->has('sha1')) {
return [$path => $parameters];
}

$parameters['sha1'] = sha1_file(
config('filesystems.disks.temp.root')
->append(
str($path)->start('/')->start($buildState->getTempPrefix())
)
);
$old_sha1 = $parameters->get('sha1');

$newPath = str($path)->replace($old_sha1, $parameters['sha1'])->toString();
$parameters['sha1'] = sha1_file(
config('filesystems.disks.temp.root')
->append(
str($path)->start('/')->start($buildState->getTempPrefix())
)
);

Storage::disk('temp')->move(
str($path)->start('/')->start($buildState->getTempPrefix()),
str($newPath)->start('/')->start($buildState->getTempPrefix())
);
$newPath = str($path)->replace($old_sha1, $parameters['sha1'])->toString();

return [$newPath => $parameters];
}
Storage::disk('temp')->move(
str($path)->start('/')->start($buildState->getTempPrefix()),
str($newPath)->start('/')->start($buildState->getTempPrefix())
);

return [$newPath => $parameters];
});

Storage::disk('temp')->put($packages_path, json_encode($packages->toArray(), JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
Expand Down

0 comments on commit 7e86967

Please sign in to comment.