File: pack.php

package info (click to toggle)
jsjac 1.3.4%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 748 kB
  • sloc: javascript: 3,033; perl: 2,699; php: 927; makefile: 78
file content (27 lines) | stat: -rwxr-xr-x 663 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
// you can pass this script to PHP CLI to convert your file.

if ($argc >= 3) {
	$src = $argv[1];
	$out = $argv[2];
} else {
	echo 'you must specify  a source file and a result filename',"\n";
	echo 'example :', "\n", 'php example-file.php myScript-src.js myPackedScript.js',"\n";
	return;
}

require 'class.JavaScriptPacker.php';

$script = file_get_contents($src);

$t1 = microtime(true);

$packer = new JavaScriptPacker($script, 'Normal', true, false);
$packed = $packer->pack();

$t2 = microtime(true);
$time = sprintf('%.4f', ($t2 - $t1) );
echo 'script ', $src, ' packed in ' , $out, ', in ', $time, ' s.', "\n";

file_put_contents($out, $packed);
?>