Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 57 lines (49 sloc) 1.544 kB
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 module Format = BaseFormat
19 module Arg = BaseArg
20 module String = BaseString
21
22 let minify = ref false
23 let files = ref []
24 let cleanup = ref false
25
26 let () =
27 let options =
28 Arg.align (
29 Arg.sort [
30 "--minify", Arg.Set minify, "";
31 "--clean-up", Arg.Set cleanup, "";
32 ]
33 ) in
34 let anon s = files := s :: !files in
35 let usage = "" in
36 Arg.parse options anon usage;
37 files := List.rev !files
38
39 let () =
40 List.iter
41 (fun filename ->
42 let code = JsParse.File.code filename in
43 let code =
44 if !cleanup then
45 Imp_CleanUp.clean ~use_shortcut_assignment:true code
46 else
47 code in
48 let string = Format.to_string JsPrint.pp#code code in
49 let string =
50 if !minify then
51 JsMinify.minify string
52 else
53 string in
54 print_string string;
55 Printf.printf "\n%!";
56 ) !files
Something went wrong with that request. Please try again.