Skip to content

Commit 20f3f73

Browse files
committed
Self review 🤓
1 parent b7b72e2 commit 20f3f73

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

‎src/PackageJsonSynchronizer.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ private function resolveImportMapPackages($phpPackage): array
147147
}
148148

149149
$dependencies = [];
150+
150151
foreach ($packageJson->read()['symfony']['importmap'] ?? [] as $importMapName => $constraintConfig) {
151152
if (\is_string($constraintConfig)) {
152153
// Case "jquery": "^3.0" | "@mybundle/script.js": "path:%PACKAGE%/script.js"
@@ -278,14 +279,12 @@ private function updateImportMap(array $importMapEntries): void
278279
$this->io->writeError(sprintf('Updating package <comment>%s</> from <info>%s</> to <info>%s</>.', $name, $version, $versionConstraint));
279280
}
280281

281-
$arguments = [];
282282
if (isset($importMapEntry['path'])) {
283+
$arguments = [$name, '--path='.$importMapEntry['path']];
283284
if (isset($importMapEntry['entrypoint']) && true === $importMapEntry['entrypoint']) {
284285
$arguments[] = '--entrypoint';
285286
}
286287

287-
$arguments[] = $name;
288-
$arguments[] = '--path='.$importMapEntry['path'];
289288
$this->scriptExecutor->execute(
290289
'symfony-cmd',
291290
'importmap:require',
@@ -300,7 +299,7 @@ private function updateImportMap(array $importMapEntries): void
300299
if ($importMapEntry['package'] !== $name) {
301300
$packageName .= '='.$name;
302301
}
303-
$arguments[] = $packageName;
302+
$arguments = [$packageName];
304303
$this->scriptExecutor->execute(
305304
'symfony-cmd',
306305
'importmap:require',

‎tests/PackageJsonSynchronizerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,8 @@ public function testSynchronizeAssetMapperNewPackage()
331331
->withConsecutive(
332332
['symfony-cmd', 'importmap:require', ['@hotcake/foo@^1.9.0']],
333333
['symfony-cmd', 'importmap:require', ['@symfony/new-package', '--path='.$fileModulePath]],
334-
['symfony-cmd', 'importmap:require', ['--entrypoint', '@symfony/new-package/entry.js', '--path='.$entrypointPath]],
335-
['symfony-cmd', 'importmap:require', ['--entrypoint', '@symfony/new-package/entry2.js', '--path='.$secondEntrypointPath]]
334+
['symfony-cmd', 'importmap:require', ['@symfony/new-package/entry.js', '--path='.$entrypointPath, '--entrypoint']],
335+
['symfony-cmd', 'importmap:require', ['@symfony/new-package/entry2.js', '--path='.$secondEntrypointPath, '--entrypoint']],
336336
);
337337

338338
$this->synchronizer->synchronize([
@@ -412,8 +412,8 @@ public function testSynchronizeAssetMapperUpgradesPackageIfNeeded()
412412
->withConsecutive(
413413
['symfony-cmd', 'importmap:require', ['@hotcake/foo@^1.9.0']],
414414
['symfony-cmd', 'importmap:require', ['@symfony/new-package', '--path='.$fileModulePath]],
415-
['symfony-cmd', 'importmap:require', ['--entrypoint', '@symfony/new-package/entry.js', '--path='.$entrypointPath]],
416-
['symfony-cmd', 'importmap:require', ['--entrypoint', '@symfony/new-package/entry2.js', '--path='.$secondEntrypointPath]]
415+
['symfony-cmd', 'importmap:require', ['@symfony/new-package/entry.js', '--path='.$entrypointPath, '--entrypoint']],
416+
['symfony-cmd', 'importmap:require', ['@symfony/new-package/entry2.js', '--path='.$secondEntrypointPath, '--entrypoint']]
417417
);
418418

419419
$this->synchronizer->synchronize([
@@ -445,7 +445,7 @@ public function testSynchronizeAssetMapperSkipsUpgradeIfAlreadySatisfied()
445445
->method('execute')
446446
->withConsecutive(
447447
['symfony-cmd', 'importmap:require', ['@symfony/new-package', '--path='.$fileModulePath]],
448-
['symfony-cmd', 'importmap:require', ['--entrypoint', '@symfony/new-package/entry.js', '--path='.$entrypointPath]],
448+
['symfony-cmd', 'importmap:require', ['@symfony/new-package/entry.js', '--path='.$entrypointPath, '--entrypoint']],
449449
);
450450

451451
$this->synchronizer->synchronize([

0 commit comments

Comments
 (0)