Skip to content

Commit

Permalink
fixed node path with real path
Browse files Browse the repository at this point in the history
  • Loading branch information
HillLiu committed Apr 18, 2021
1 parent cc9da47 commit c69f9aa
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions nodejs.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ public function init()
if (!$this[NODEJS]) {
$this->_initNodePath();
} else {
if (!\PMVC\realPath($this[NODEJS])) {
$nodejs = \PMVC\realPath($this[NODEJS]);
if (!$nodejs) {
throw new InvalidArgumentException(
'NodeJs path was not found. [' . $this[NODEJS] . ']'
);
} else {
$this[NODEJS] = $nodejs;
}
}
}
Expand All @@ -36,11 +39,11 @@ public function getNodeJs()

private function _initNodePath()
{
$alpinePath = '/usr/bin/node';
$vendorPath = __DIR__ . '/../../bin/node';
if (\PMVC\realPath($alpinePath)) {
$alpinePath = \PMVC\realPath('/usr/bin/node');
$vendorPath = \PMVC\realPath(__DIR__ . '/../../bin/node');
if ($alpinePath) {
$this[NODEJS] = $alpinePath;
} elseif (\PMVC\realPath($vendorPath)) {
} elseif ($vendorPath) {
$this[NODEJS] = $vendorPath;
}
}
Expand Down

0 comments on commit c69f9aa

Please sign in to comment.