From 80c7d2794d7d1b347c6f718feaa8ec9b02e43f4f Mon Sep 17 00:00:00 2001 From: Greg Anderson Date: Thu, 14 Jun 2018 10:48:21 -0700 Subject: [PATCH] Pre-load all of our sources on initial load so that we will not get a more recent version of one of our classes e.g. after a 'composer update' operation. (#82) --- src/Handler.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Handler.php b/src/Handler.php index 8b81321..1bdefe0 100644 --- a/src/Handler.php +++ b/src/Handler.php @@ -56,6 +56,27 @@ public function __construct(Composer $composer, IOInterface $io) { $this->composer = $composer; $this->io = $io; $this->progress = TRUE; + + // Pre-load all of our sources so that we do not run up + // against problems in `composer update` operations. + $this->manualLoad(); + } + + protected function manualLoad() { + $src_dir = __DIR__; + + $classes = [ + 'CommandProvider', + 'DrupalScaffoldCommand', + 'FileFetcher', + 'PrestissimoFileFetcher', + ]; + + foreach ($classes as $src) { + if (!class_exists('\\DrupalComposer\\DrupalScaffold\\' . $src)) { + include "{$src_dir}/{$src}.php"; + } + } } /**