Skip to content

Commit

Permalink
CLI: Do not wrap main definition as a module and export directly inst…
Browse files Browse the repository at this point in the history
…ead; CLI: Generate prettier definitions with --no-comments
  • Loading branch information
dcodeIO committed Dec 31, 2016
1 parent 8052910 commit 65637ff
Show file tree
Hide file tree
Showing 7 changed files with 2,818 additions and 6,779 deletions.
22 changes: 15 additions & 7 deletions cli/pbts.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ exports.main = function(args, callback) {
var argv = minimist(args, {
alias: {
name: "n",
out : "o"
out : "o",
main: "m",
global: "g"
},
string: [ "name", "out" ],
boolean: [ "comments" ],
string: [ "name", "out", "global" ],
boolean: [ "comments", "main" ],
default: {
comments: true
comments: true,
main: false
}
});

Expand All @@ -43,9 +46,9 @@ exports.main = function(args, callback) {
"Generates TypeScript definitions from annotated JavaScript files.",
"",
" -n, --name Wraps everything in a module of the specified name.",
"",
" -o, --out Saves to a file instead of writing to stdout.",
"",
" -m, --main Whether building the main library without any imports.",
" -g, --global Name of the global object in browser environments, if any.",
" --no-comments Does not output any JSDoc comments.",
"",
"usage: " + chalk.bold.green("pbts") + " [options] file1.js file2.js ..."
Expand Down Expand Up @@ -96,7 +99,12 @@ exports.main = function(args, callback) {
"// Generated " + (new Date()).toUTCString().replace(/GMT/, "UTC"),
""
];
if (argv.name !== "protobuf")
if (argv.global)
output.push(
"export as namespace " + argv.global + ";",
""
);
if (!argv.main)
output.push(
"import * as $protobuf from \"protobufjs\";",
""
Expand Down
Loading

0 comments on commit 65637ff

Please sign in to comment.