Dotclear

source: build-tools/min-js.php @ 3730:5c45a5df9a59

Revision 3730:5c45a5df9a59, 954 bytes checked in by franck <carnet.franck.paul@…>, 7 years ago (diff)

Code formatting (PSR-2)

  • Property exe set to *
RevLine 
[0]1#!/usr/bin/env php
2<?php
3# -- BEGIN LICENSE BLOCK ---------------------------------------
4#
5# This file is part of Dotclear 2.
6#
[1179]7# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
[0]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
14try
15{
[3730]16    $js = (!empty($_SERVER['argv'][1])) ? $_SERVER['argv'][1] : null;
[2566]17
[3730]18    if (!$js || !is_file($js)) {
19        throw new Exception(sprintf("File %s does not exist", $js));
20    }
[2566]21
[3730]22    require dirname(__FILE__) . '/jsmin-1.1.1.php';
[2566]23
[3730]24    $content = file_get_contents($js);
25    $res     = JSMin::minify($content);
[2566]26
[3730]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);
[0]35}
[2566]36?>
Note: See TracBrowser for help on using the repository browser.

Sites map