Skip to content

Commit

Permalink
Also allow to override module in Typescript generator
Browse files Browse the repository at this point in the history
- Adds "-d, --dependency" cli option to pbts
- flag --dependency already presents in pbjs
  • Loading branch information
fhoering committed Feb 7, 2025
1 parent ae265f2 commit 3263839
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions cli/pbts.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ exports.main = function(args, callback) {
out : "o",
main: "m",
global: "g",
import: "i"
import: "i",
dependency: "d"
},
string: [ "name", "out", "global", "import" ],
string: [ "name", "out", "global", "import", "dependency"],
boolean: [ "comments", "main" ],
default: {
comments: true,
Expand All @@ -42,19 +43,21 @@ exports.main = function(args, callback) {
"",
chalk.bold.white("Generates TypeScript definitions from annotated JavaScript files."),
"",
" -o, --out Saves to a file instead of writing to stdout.",
" -o, --out Saves to a file instead of writing to stdout.",
"",
" -g, --global Name of the global object in browser environments, if any.",
" -g, --global Name of the global object in browser environments, if any.",
"",
" -i, --import Comma delimited list of imports. Local names will equal camelCase of the basename.",
" -i, --import Comma delimited list of imports. Local names will equal camelCase of the basename.",
"",
" --no-comments Does not output any JSDoc comments.",
" --no-comments Does not output any JSDoc comments.",
"",
chalk.bold.gray(" Internal flags:"),
"",
" -n, --name Wraps everything in a module of the specified name.",
" -n, --name Wraps everything in a module of the specified name.",
"",
" -m, --main Whether building the main library without any imports.",
" -m, --main Whether building the main library without any imports.",
"",
" -d, --dependency Specifies which version of protobuf to require. Accepts any valid module id.",
"",
"usage: " + chalk.bold.green("pbts") + " [options] file1.js file2.js ..." + chalk.bold.gray(" (or) ") + "other | " + chalk.bold.green("pbts") + " [options] -",
""
Expand Down Expand Up @@ -159,7 +162,7 @@ exports.main = function(args, callback) {

// Build an object of imports and paths
var imports = {
$protobuf: "protobufjs"
$protobuf: argv.dependency || "protobufjs"
};
importArray.forEach(function(importItem) {
imports[getImportName(importItem)] = importItem;
Expand Down

0 comments on commit 3263839

Please sign in to comment.