From 890080c046c739244b0c13228c6886dca1c153f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Ulsberg?= Date: Mon, 13 Nov 2017 22:09:29 +0100 Subject: [PATCH] Detect where md2resume is installed and traverse folders accordingly --- bin/md2resume | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/md2resume b/bin/md2resume index 55edc53..f5f86c6 100755 --- a/bin/md2resume +++ b/bin/md2resume @@ -6,14 +6,20 @@ $baseDir = dirname(__DIR__); $templatePath = $baseDir . '/templates'; $consoleTemplatePath = $baseDir . '/src/Resume/Templates'; +// When md2resume is installed with composer, it resides in the a +// 'markdown-resume' subdirectory of the 'vendor' directory, so we need to +// walk up a few folders to find 'autoload.php'. +$autoloadPath = basename($baseDir) === 'markdown-resume' + ? realpath($baseDir . '/../../autoload.php') + : $baseDir . '/vendor/autoload.php'; + // If the dependencies aren't installed, we have to bail and offer some help. -$autoloadPath = $baseDir . '/vendor/autoload.php'; if (!file_exists($autoloadPath)) { exit("\nThe dependency '$autoloadPath' was not found. Please run `composer install` to install dependencies.\n\n"); } // Bootstrap our application with the Composer autoloader -$app = include $baseDir . '/vendor/autoload.php'; +$app = include $autoloadPath; // Setup the namespace for our own namespace $app->add('Resume', $baseDir . '/src');