/** * Overrides WordlessPreprocessor::process_file() */ protected function process_file($file_path, $result_path, $temp_path) { $this->validate_executable_or_die($this->preference("sprockets.ruby_path")); // On cache miss, we build the JS file from scratch $pb = new ProcessBuilder(array($this->preference("sprockets.ruby_path"), Wordless::join_paths(dirname(__FILE__), "sprockets_preprocessor.rb"))); // Fix for MAMP environments, see http://goo.gl/S5KFe for details $pb->setEnv("DYLD_LIBRARY_PATH", ""); $pb->add(Wordless::theme_static_javascripts_path()); $pb->add(Wordless::theme_javascripts_path()); $pb->add($file_path); $proc = $pb->getProcess(); $code = $proc->run(); if ($code != 0) { $this->die_with_error($proc->getErrorOutput()); } return $proc->getOutput(); }
/** * Overrides WordlessPreprocessor::process_file() */ protected function process_file($file_path, $temp_path) { $this->validate_executable_or_throw($this->preference("js.ruby_path")); // On cache miss, we build the JS file from scratch $pb = new ProcessBuilder(array($this->preference("js.ruby_path"), Wordless::join_paths(dirname(__FILE__), "sprockets_preprocessor.rb"), "compile")); // Fix for MAMP environments, see http://goo.gl/S5KFe for details $pb->setEnv("DYLD_LIBRARY_PATH", ""); $pb->add($file_path); $pb->add("--paths"); $pb->add(Wordless::theme_static_javascripts_path()); $pb->add(Wordless::theme_javascripts_path()); if ($this->preference("js.yui_compress")) { $pb->add("--compress"); } if ($this->preference("js.yui_munge")) { $pb->add("--munge"); } $proc = $pb->getProcess(); $code = $proc->run(); if ($code != 0) { throw new WordlessCompileException("Failed to run the following command: " . $proc->getCommandLine(), $proc->getErrorOutput()); } return $proc->getOutput(); }
/** * Process a file, executing Compass executable. * * Execute the Compass executable, overriding the no-op function inside * WordlessPreprocessor. */ protected function process_file($file_path, $temp_path) { $this->validate_executable_or_throw($this->preference("css.compass_path")); // On cache miss, we build the file from scratch $pb = new ProcessBuilder(array($this->preference("css.compass_path"), 'compile', $temp_path)); $config = array("http_path" => "./", "http_images_dir" => "../images", "images_dir" => "../assets/images", "http_fonts_dir" => "../fonts", "fonts_dir" => "../assets/fonts", "css_path" => $temp_path, "relative_assets" => false, "output_style" => ":" . $this->preference("css.output_style"), "environment" => ":production", "sass_path" => dirname($file_path)); $ruby_config = array(); foreach ($this->preference("css.require_libs") as $lib) { $ruby_config[] = sprintf('require "%s"', $lib); } foreach ($config as $name => $value) { if (strpos($value, ":") === 0) { $ruby_config[] = sprintf('%s = %s', $name, $value); } else { if (is_bool($value)) { $ruby_config[] = sprintf('%s = %s', $name, $value ? "true" : "false"); } else { $ruby_config[] = sprintf('%s = "%s"', $name, addcslashes($value, '\\')); } } } $config_path = tempnam($temp_path, 'compass_config'); file_put_contents($config_path, implode("\n", $ruby_config) . "\n"); $pb->add("--config")->add($config_path); $output = $temp_path . "/" . basename($file_path, pathinfo($file_path, PATHINFO_EXTENSION)) . 'css'; $proc = $pb->getProcess(); $code = $proc->run(); if (0 < $code) { unlink($config_path); throw new WordlessCompileException("Failed to run the following command: " . $proc->getCommandLine() . "\n" . "Generated config:\n" . implode("\n", $ruby_config), $proc->getErrorOutput()); } unlink($config_path); return file_get_contents($output); }
/** * Process a file, executing Compass executable. * * Execute the Compass executable, overriding the no-op function inside * WordlessPreprocessor. */ protected function process_file($file_path, $result_path, $temp_path) { $this->validate_executable_or_die($this->preference("compass.compass_path")); // On cache miss, we build the file from scratch $pb = new ProcessBuilder(array($this->preference("compass.compass_path"), 'compile', $temp_path)); $config = array("http_path" => Wordless::theme_url(), "images_dir" => "assets/images", "css_path" => $temp_path, "relative_assets" => false, "output_style" => ":" . $this->preference("compass.output_style"), "environment" => ":production", "sass_path" => dirname($file_path)); $ruby_config = array(); foreach ($config as $name => $value) { if (strpos($value, ":") === 0) { $ruby_config[] = sprintf('%s = %s', $name, $value); } else { if (is_bool($value)) { $ruby_config[] = sprintf('%s = %s', $name, $value ? "true" : "false"); } else { $ruby_config[] = sprintf('%s = "%s"', $name, addcslashes($value, '\\')); } } } $config_path = tempnam($temp_path, 'compass_config'); file_put_contents($config_path, implode("\n", $ruby_config) . "\n"); $pb->add("--config")->add($config_path); $output = $temp_path . "/" . basename($file_path, pathinfo($file_path, PATHINFO_EXTENSION)) . 'css'; $proc = $pb->getProcess(); $code = $proc->run(); if (0 < $code) { unlink($config_path); $this->die_with_error($proc->getErrorOutput()); } unlink($config_path); return file_get_contents($output); }
/** * Process a file, executing lessc executable. * * Execute the lessc executable, overriding the no-op function inside * WordlessPreprocessor. * * If using php-fpm, remember to pass the PATH environment variable * in php-fpm.ini (e.g. env[PATH]=/usr/local/bin:/usr/bin:/bin) */ protected function process_file($file_path, $temp_path) { $this->validate_executable_or_throw($this->preference("css.lessc_path")); // On cache miss, we build the file from scratch $pb = new ProcessBuilder(array($this->preference("css.lessc_path"), $file_path)); // Since the official lessc executable relies on node.js, we need to // inherit env to get access to $PATH so we can find the node executable $pb->inheritEnvironmentVariables(); if ($this->preference("css.compress")) { $pb->add("-compress"); } $proc = $pb->getProcess(); $code = $proc->run(); if (0 < $code) { throw new WordlessCompileException("Failed to run the following command: " . $proc->getCommandLine(), $proc->getErrorOutput()); } return $proc->getOutput(); }