Permalink
Browse files

CLI: Do not wrap main definition as a module and export directly inst…

…ead; CLI: Generate prettier definitions with --no-comments
  • Loading branch information...
dcodeIO committed Dec 31, 2016
1 parent 8052910 commit 65637ffce20099df97ffbcdce50faccc8e97c366
Showing with 2,818 additions and 6,779 deletions.
  1. +15 −7 cli/pbts.js
  2. +2,101 −2,102 index.d.ts
  3. +25 −16 lib/tsd-jsdoc/publish.js
  4. +1 −1 package.json
  5. +1 −1 scripts/gentests.js
  6. +674 −4,651 tests/data/test.d.ts
  7. +1 −1 tests/typescript.ts
@@ -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
}
});

@@ -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 ..."
@@ -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\";",
""
Oops, something went wrong.

0 comments on commit 65637ff

Please sign in to comment.