/** Common */ public function testExec() { ob_start(); $exec = new Commands\Exec(); $exec->setCommand('echo "testexec"'); $result = $exec->execute(); $output = $result->getOutput(); $line = $output[0]; $this->assertEquals('testexec', trim($line, '"')); // on windows there are quotes ob_end_clean(); }
public function execute($gulpCommand = NULL) { $path = $this->directory . DIRECTORY_SEPARATOR . $this->gulpfile; if (!file_exists($path)) { $this->error(sprintf("Cannot find gulpfile '%s'.", $path)); } $cmd = 'cd ' . escapeshellarg($this->directory) . ' && gulp ' . $gulpCommand; $command = new Commands\Exec(); $command->setCommand($cmd); $result = $command->execute(); if ($result->getResult() !== 0) { $this->error(sprintf("Gulp task '%s' in directory %s failed.", $gulpCommand, $this->directory)); } return $result; }
public function execute() { $cmd = $this->nodeVersionCommand; $command = new Commands\Exec(); $command->setCommand($cmd); $result = $command->execute(); if ($result->getResult() !== 0) { $this->error(sprintf('Execution of command "%s" failed.', $cmd)); } $version = $result->getOutput()[0]; if (version_compare($version, $this->requiredVersion) < 0) { $this->error(sprintf('Node.JS is not current. Version %s required, but %s is installed.', $this->requiredVersion, $version)); } $this->log(sprintf('Required Node.JS version %s satisfied with installed version %s.', $this->requiredVersion, $version)); }
public function execute() { $cmd = 'cd ' . escapeshellarg($this->directory) . ' && npm install'; if (isset($this->options['silent']) && $this->options['silent']) { $cmd .= ' --silent'; // supress warnings } $command = new Exec(); $command->setCommand($cmd); $result = $command->execute(); if ($result->getResult() !== 0) { $this->error(sprintf('Installation of node modules for package in dir "%s" failed.', $this->directory)); } $this->log("Npm installed modules successfully."); return $result; }
/** * target is relative to link! * eg: dir, ../mydir, public/symdir */ public function createRelative($directory, $target, $link) { if (!is_dir($directory)) { $this->error("Directory '{$directory}' not found."); } if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $cmd = 'cd ' . escapeshellarg($directory) . ' && mklink ' . ' /D ' . escapeshellarg($link) . ' ' . escapeshellarg($target); } else { $cmd = 'cd ' . escapeshellarg($directory) . ' && ln -s ' . escapeshellarg($target) . ' ' . escapeshellarg($link); } $command = new Commands\Exec(); $command->setCommand($cmd); $result = $command->execute(); if ($result->getResult() !== 0) { $this->error("Cannot create symlink '{$target}' - '{$link}' in directory '{$directory}'."); } return $result; }
public function execute() { if (count($this->files) === 0) { return; } $opts = '--no-color --verbose '; if (isset($this->options['compress']) && $this->options['compress']) { $opts .= '--compress '; } if (isset($this->options['relativeUrls']) && $this->options['relativeUrls']) { $opts .= '--relative-urls '; } foreach ($this->files as $source => $target) { $cmd = escapeshellarg($this->executable) . ' ' . $opts . escapeshellarg($source) . ' ' . escapeshellarg($target); $command = new Commands\Exec(); $command->setCommand($cmd); $result = $command->execute(); if ($result->getResult() !== 0) { $this->error(sprintf("LESS compilation of file '%s' failed.", $source)); } } }
private function exec($command) { $exec = new Exec(); $exec->setCommand($command); return $exec->execute(); }