Skip to content

Commit

Permalink
improve assign nodejs
Browse files Browse the repository at this point in the history
  • Loading branch information
HillLiu committed Aug 17, 2017
1 parent 49ee0dd commit cfd4260
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions view_react.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
* Parameters
* @parameters string NODE node bin path
* @parameters string NODEJS node bin path
* @parameters string reactData
* @parameters string CSS
* @parameters string jsFile custom js path
Expand All @@ -23,9 +23,7 @@ public function init()
'X-Accel-Buffering: no',
'Content-Encoding: none'
];
if (!isset($this['NODE'])) {
$this['NODE'] = \PMVC\plug('get')->get('NODE');
}
$this['NODEJS'] = \PMVC\realpath($this['NODEJS']);
}

private function _shell($command, $input, &$returnCode)
Expand All @@ -48,12 +46,13 @@ private function _shell($command, $input, &$returnCode)

private function _run()
{
if (empty($this['NODE'])) {
if (empty($this['NODEJS'])) {
return false;
}
// echo '{"themePath":"home"}' | node ./server.js
$js = \PMVC\value($this, ['jsFile'], $this['themeFolder'].'/server.js');
$cmd = $this['NODE'].' '.$js;
$js = \PMVC\realPath($js);
$cmd = $this['NODEJS'].' '.$js;
\PMVC\dev(function() use($cmd) {
$s = "echo '".$this['reactData']."' | ".$cmd;
return $s;
Expand Down

0 comments on commit cfd4260

Please sign in to comment.