Skip to content

Commit

Permalink
chore: throw exception if node/mjml not found
Browse files Browse the repository at this point in the history
fixes #20

Signed-off-by: Fred Carlsen <[email protected]>
  • Loading branch information
sjelfull committed May 27, 2024
1 parent 27610cd commit d5705c7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/services/MJMLService.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use superbig\mjml\models\MJMLModel;
use yii\base\ErrorException;
use yii\base\Exception;
use yii\base\InvalidConfigException;

/**
* @author Superbig
Expand Down Expand Up @@ -125,6 +126,16 @@ public function parseCli(?string $html = null): ?MJMLModel
$tempPath = Craft::$app->getPath()->getTempPath() . "/mjml/mjml-{$hash}.html";
$tempOutputPath = Craft::$app->getPath()->getTempPath() . "/mjml/mjml-output-{$hash}.html";

// Check if Node.js exists
if (!file_exists($nodePath)) {
throw new InvalidConfigException("Node.js executable not found at path: {$nodePath}");
}

// Check if MJML CLI exists
if (!file_exists($mjmlCliPath)) {
throw new InvalidConfigException("MJML CLI executable not found at path: {$mjmlCliPath}");
}

try {
if (!file_exists($tempOutputPath)) {
FileHelper::writeToFile($tempPath, $html);
Expand Down

0 comments on commit d5705c7

Please sign in to comment.