Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $file = isset($argv[1]) ? $argv[1] : null;
- if (empty($file)) {
- printf("USAGE: %s file.js", $argv[0]);
- exit;
- }
- if (!is_file($file)) {
- printf("ERROR: File does not exist: %s", $file);
- }
- $content = file_get_contents($file);
- $content = preg_replace_callback('/`(.*?)`/s', function($groups) {
- $value = $groups[1];
- $value = preg_replace_callback("/(\r?\n)/", function($groups) {
- return '\n\\' . $groups[1];
- }, $value);
- $quote = '"';
- $value = $quote. addcslashes($value, $quote) . $quote;
- return $value;
- }, $content);
- file_put_contents($file, $content);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement