function build($argv) { $input = new lmbCliInput(); $input->setMinimumArguments(2); $input->read($argv, false); $arguments = $input->getArguments(); if (!($dest_file = array_pop($arguments))) { echo "Error: You must specify output file.\n"; return 1; } $src_files = array(); foreach ($arguments as $src_file) { $src_files[] = realpath($src_file); } if (empty($src_files)) { echo "Error: You must specify at least one input file.\n"; return 1; } $builder = new lmbJsPreprocessor(); try { $contents = $builder->processFiles($src_files); } catch (lmbException $e) { echo 'Build error: ' . $e->getMessage(); return 1; } lmbFs::safeWrite($dest_file, $contents); return 0; }
function testIncludeSeveralFiles() { $this->_createFile($file1 = 'foo.js', <<<EOD //#include "bar.js" //#include "wow.js" foo EOD ); $this->_createFile($file2 = 'bar.js', <<<EOD bar EOD ); $this->_createFile($file3 = 'wow.js', <<<EOD //#include "bar.js" wow EOD ); $builder = new lmbJsPreprocessor(); $this->assertEqual($builder->processFiles(array($this->_getFile($file1), $this->_getFile($file1))), <<<EOD bar wow foo EOD ); }