Line | |
---|
1 | #!/usr/bin/env php |
---|
2 | <?php |
---|
3 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
4 | # |
---|
5 | # This file is part of Dotclear 2. |
---|
6 | # |
---|
7 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
8 | # Licensed under the GPL version 2.0 license. |
---|
9 | # See LICENSE file or |
---|
10 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
11 | # |
---|
12 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
13 | |
---|
14 | try |
---|
15 | { |
---|
16 | $js = (!empty($_SERVER['argv'][1])) ? $_SERVER['argv'][1] : null; |
---|
17 | |
---|
18 | if (!$js || !is_file($js)) { |
---|
19 | throw new Exception(sprintf("File %s does not exist", $js)); |
---|
20 | } |
---|
21 | |
---|
22 | require dirname(__FILE__) . '/jsmin-1.1.1.php'; |
---|
23 | |
---|
24 | $content = file_get_contents($js); |
---|
25 | $res = JSMin::minify($content); |
---|
26 | |
---|
27 | if (($fp = fopen($js, 'wb')) === false) { |
---|
28 | throw new Exception(sprintf('Unable to open file %s', $js)); |
---|
29 | } |
---|
30 | fwrite($fp, $res); |
---|
31 | fclose($fp); |
---|
32 | } catch (Exception $e) { |
---|
33 | fwrite(STDERR, $e->getMessage() . "\n"); |
---|
34 | exit(1); |
---|
35 | } |
---|
36 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.