/**
  * This method is invoked right before an action is to be executed (after all possible filters.)
  * It checks the existence of the [[migrationPath]].
  * @param \yii\base\Action $action the action to be executed.
  * @throws Exception if directory specified in migrationPath doesn't exist and action isn't "create".
  * @return boolean whether the action should continue to be executed.
  */
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         $path = Leaps::getAlias($this->migrationPath);
         if (!is_dir($path)) {
             if ($action->id !== 'create') {
                 throw new Exception("Migration failed. Directory specified in migrationPath doesn't exist: {$this->migrationPath}");
             }
             FileHelper::createDirectory($path);
         }
         $this->migrationPath = $path;
         $version = Leaps::getVersion();
         $this->stdout("Leaps Migration Tool (based on Leaps v{$version})\n\n");
         return true;
     } else {
         return false;
     }
 }