From c69f9aac36ca75b2aff2b7814550fed479679599 Mon Sep 17 00:00:00 2001 From: Hill Date: Sun, 18 Apr 2021 23:13:06 +0800 Subject: [PATCH] fixed node path with real path --- nodejs.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/nodejs.php b/nodejs.php index cee8097..fa17ef2 100755 --- a/nodejs.php +++ b/nodejs.php @@ -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; } } } @@ -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; } }