Skip to content

Commit

Permalink
Use the package name in the pin first argument instead of the new for…
Browse files Browse the repository at this point in the history
…mat (so it works on all installs)
  • Loading branch information
tonysm committed Feb 4, 2024
1 parent 0cfdcb1 commit ac86d49
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Npm.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private function findPackagesFromCdnMatches(string $content)

private function findPackagesFromLocalMatches(string $content)
{
preg_match_all('/^Importmap::pin\(.+\)\;\s*\/\/\s*(.+?)@(.+?)\s+.*\r?$/m', $content, $matches);
preg_match_all('/^Importmap::pin\([\'\"](.+?)[\'\"].*\)\;\s*\/\/\s*.*@(.+?)\s+.*\r?$/m', $content, $matches);

if (count($matches) !== 3) {
return collect();
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/npm/audit-importmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
use Tonysm\ImportmapLaravel\Facades\Importmap;

Importmap::pin('is-svg', to: 'https://cdn.skypack.dev/[email protected]', preload: true);
Importmap::pin('lodash', to: '/js/vendor/lodash.js'); // lodash@4.17.12
Importmap::pin('lodash', to: '/js/vendor/lodash.js'); // @4.17.12
2 changes: 1 addition & 1 deletion tests/fixtures/npm/outdated-importmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
use Tonysm\ImportmapLaravel\Facades\Importmap;

Importmap::pin('is-svg', to: 'https://cdn.skypack.dev/[email protected]', preload: true);
Importmap::pin('lodash', to: '/js/vendor/lodash.js'); // lodash@4.0.0
Importmap::pin('lodash', to: '/js/vendor/lodash.js'); // @4.0.0

0 comments on commit ac86d49

Please sign in to comment.