@@ -22,12 +22,15 @@ exports.main = function(args, callback) {
2222 var argv = minimist ( args , {
2323 alias : {
2424 name : "n" ,
25- out : "o"
25+ out : "o" ,
26+ main : "m" ,
27+ global : "g"
2628 } ,
27- string : [ "name" , "out" ] ,
28- boolean : [ "comments" ] ,
29+ string : [ "name" , "out" , "global" ] ,
30+ boolean : [ "comments" , "main" ] ,
2931 default : {
30- comments : true
32+ comments : true ,
33+ main : false
3134 }
3235 } ) ;
3336
@@ -43,9 +46,9 @@ exports.main = function(args, callback) {
4346 "Generates TypeScript definitions from annotated JavaScript files." ,
4447 "" ,
4548 " -n, --name Wraps everything in a module of the specified name." ,
46- "" ,
4749 " -o, --out Saves to a file instead of writing to stdout." ,
48- "" ,
50+ " -m, --main Whether building the main library without any imports." ,
51+ " -g, --global Name of the global object in browser environments, if any." ,
4952 " --no-comments Does not output any JSDoc comments." ,
5053 "" ,
5154 "usage: " + chalk . bold . green ( "pbts" ) + " [options] file1.js file2.js ..."
@@ -96,7 +99,12 @@ exports.main = function(args, callback) {
9699 "// Generated " + ( new Date ( ) ) . toUTCString ( ) . replace ( / G M T / , "UTC" ) ,
97100 ""
98101 ] ;
99- if ( argv . name !== "protobuf" )
102+ if ( argv . global )
103+ output . push (
104+ "export as namespace " + argv . global + ";" ,
105+ ""
106+ ) ;
107+ if ( ! argv . main )
100108 output . push (
101109 "import * as $protobuf from \"protobufjs\";" ,
102110 ""
0 commit comments