Skip to content
Snippets Groups Projects

Issue #3257134: Don't stage node_modules directories

4 unresolved threads

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
5 use Drupal\package_manager\Event\PreApplyEvent;
6 use Drupal\package_manager\Event\PreCreateEvent;
7 use Drupal\package_manager\Event\StageEvent;
8 use Drupal\package_manager\PathLocator;
9 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
10 use Symfony\Component\Finder\Finder;
11
12 /**
13 * Excludes node_modules files from staging areas.
14 *
15 * @internal
16 * This is an internal part of Package Manager and may be changed or removed
17 * at any time without warning. External code should not interact with this
18 * class.
19 */
20 class NodeModuleExcluder implements EventSubscriberInterface {
  • 32 }
    33
    34 /**
    35 * Excludes node_modules directory from staging operations.
    36 *
    37 * @param \Drupal\package_manager\Event\PreApplyEvent|\Drupal\package_manager\Event\PreCreateEvent $event
    38 * The event object.
    39 *
    40 * @see \Drupal\package_manager\Event\ExcludedPathsTrait::excludePath()
    41 */
    42 public function excludeNodeModulesFiles(StageEvent $event): void {
    43 $finder = Finder::create()
    44 ->in($this->pathLocator->getProjectRoot())
    45 ->directories()
    46 ->name('.git')
    47 ->name(['.git', 'node_modules'])
  • 25 }
    26
    27 /**
    28 * Tests that certain paths are excluded from staging operations.
    29 */
    30 public function testExcludedPaths(): void {
    31 // In this test, we want to perform the actual staging operations so that we
    32 // can be sure that files are staged as expected.
    33 $this->setSetting('package_manager_bypass_composer_stager', FALSE);
    34 // Ensure we have an up-to-date container.
    35 $this->container = $this->container->get('kernel')->rebuildContainer();
    36
    37 $active_dir = $this->container->get('package_manager.path_locator')
    38 ->getProjectRoot();
    39
    40 $stage = $this->createStage();
  • This mostly looks pretty good to me. There seems to be some copypasta left over that needs to be cleaned up, and I think the test should probably just rely on actual files added to the fake_site fixture.

  • 10 use Symfony\Component\Finder\Finder;
    11
    12 /**
    13 * Excludes node_modules files from staging areas.
    14 *
    15 * @internal
    16 * This is an internal part of Package Manager and may be changed or removed
    17 * at any time without warning. External code should not interact with this
    18 * class.
    19 */
    20 class NodeModuleExcluder implements EventSubscriberInterface {
    21
    22 use PathExclusionsTrait;
    23
    24 /**
    25 * Constructs an ExcludedPathsSubscriber.
  • Yash Rode added 10 commits

    added 10 commits

    Compare with previous version

  • Adam G-H added 1 commit

    added 1 commit

    Compare with previous version

  • Adam G-H added 1 commit

    added 1 commit

    Compare with previous version

  • Adam G-H added 1 commit

    added 1 commit

    • fa59358a - Add coverage of pre-apply exclusion too

    Compare with previous version

  • Adam G-H added 1 commit

    added 1 commit

    Compare with previous version

  • merged

  • Please register or sign in to reply
    Loading