protobufjs-cli
Advanced tools
+18
-0
| # Changelog | ||
| ## [2.5.2](https://github.com/protobufjs/protobuf.js/compare/protobufjs-cli-v2.5.1...protobufjs-cli-v2.5.2) (2026-06-07) | ||
| ### Bug Fixes | ||
| * **cli:** Consistently wait for pbts output before JSDoc exit ([#2306](https://github.com/protobufjs/protobuf.js/issues/2306)) ([87ff02f](https://github.com/protobufjs/protobuf.js/commit/87ff02fbae6b118f7d9f03bf5ba2cf3eb5c5f774)) | ||
| * **cli:** Preserve indentation in multiline declarations ([#2307](https://github.com/protobufjs/protobuf.js/issues/2307)) ([b38748d](https://github.com/protobufjs/protobuf.js/commit/b38748de9de4e38c7c3fa0b4962fc9ef77cc3669)) | ||
| * Preserve descriptor metadata needed by protoc-gen-pbjs ([#2308](https://github.com/protobufjs/protobuf.js/issues/2308)) ([a3b8dc7](https://github.com/protobufjs/protobuf.js/commit/a3b8dc7d55ff575baf0485a4467535d60d68c9e6)) | ||
| ### Dependencies | ||
| * The following workspace dependencies were updated | ||
| * devDependencies | ||
| * protobufjs bumped from file:.. to 8.6.1 | ||
| * peerDependencies | ||
| * protobufjs bumped from ^8.6.0 to ^8.6.1 | ||
| ## [2.5.1](https://github.com/protobufjs/protobuf.js/compare/protobufjs-cli-v2.5.0...protobufjs-cli-v2.5.1) (2026-06-04) | ||
@@ -4,0 +22,0 @@ |
+30
-16
@@ -5,3 +5,3 @@ "use strict"; | ||
| // output stream | ||
| // output chunks | ||
| var out = null; | ||
@@ -57,9 +57,5 @@ | ||
| // setup output | ||
| out = options.destination | ||
| ? fs.createWriteStream(options.destination) | ||
| : process.stdout; | ||
| try { | ||
| // setup environment | ||
| out = []; | ||
| data = taffy().get(); | ||
@@ -90,5 +86,14 @@ indent = 0; | ||
| // close file output | ||
| if (out !== process.stdout) | ||
| out.end(); | ||
| // Let JSDoc wait for output to flush before exiting | ||
| return new Promise(function(resolve, reject) { | ||
| function done(err) { | ||
| if (err) | ||
| reject(err); | ||
| else | ||
| resolve(); | ||
| } | ||
| // Use stdout fd 1 directly because uv_guess_handle can fail to classify | ||
| // sandboxed stdout handles when getsockname/getsockopt raises EPERM. | ||
| fs.writeFile(options.destination || 1, out.join(""), "utf8", done); | ||
| }); | ||
@@ -108,9 +113,18 @@ } finally { | ||
| function write() { | ||
| var s = Array.prototype.slice.call(arguments).join(""); | ||
| if (!indentWritten) { | ||
| for (var i = 0; i < indent; ++i) | ||
| s = " " + s; | ||
| indentWritten = true; | ||
| var lines = Array.prototype.slice.call(arguments).join("").replace(/\r?\n|\r/g, "\n").split("\n"); | ||
| for (var i = 0; i < lines.length; ++i) { | ||
| var s = lines[i]; | ||
| if (i) { | ||
| out.push("\n"); | ||
| indentWritten = false; | ||
| } | ||
| if (s.length) { | ||
| if (!indentWritten) { | ||
| for (var j = 0; j < indent; ++j) | ||
| s = " " + s; | ||
| indentWritten = true; | ||
| } | ||
| out.push(s); | ||
| } | ||
| } | ||
| out.write(s); | ||
| firstLine = false; | ||
@@ -125,3 +139,3 @@ } | ||
| else if (!firstLine) | ||
| out.write("\n"); | ||
| out.push("\n"); | ||
| indentWritten = false; | ||
@@ -128,0 +142,0 @@ } |
+2
-2
| { | ||
| "name": "protobufjs-cli", | ||
| "description": "Translates between file formats and generates static code as well as TypeScript definitions.", | ||
| "version": "2.5.1", | ||
| "version": "2.5.2", | ||
| "author": "Daniel Wirtz <dcode+protobufjs@dcode.io>", | ||
@@ -23,3 +23,3 @@ "repository": { | ||
| "peerDependencies": { | ||
| "protobufjs": "^8.6.0" | ||
| "protobufjs": "^8.6.1" | ||
| }, | ||
@@ -26,0 +26,0 @@ "dependencies": { |
+10
-10
@@ -180,3 +180,3 @@ "use strict"; | ||
| file: files | ||
| })); | ||
| }), { keepCase: keepCase }); | ||
| } | ||
@@ -191,4 +191,4 @@ | ||
| if (!keepCase) { | ||
| (object.messageType || []).forEach(camelCaseMembers); | ||
| (object.extension || []).forEach(camelCaseField); | ||
| (object.messageType || []).forEach(normalizeMemberNames); | ||
| (object.extension || []).forEach(ensureJsonName); | ||
| } | ||
@@ -198,6 +198,6 @@ return object; | ||
| function camelCaseMembers(message) { | ||
| (message.field || []).forEach(camelCaseField); | ||
| (message.extension || []).forEach(camelCaseField); | ||
| (message.nestedType || []).forEach(camelCaseMembers); | ||
| function normalizeMemberNames(message) { | ||
| (message.field || []).forEach(ensureJsonName); | ||
| (message.extension || []).forEach(ensureJsonName); | ||
| (message.nestedType || []).forEach(normalizeMemberNames); | ||
| (message.oneofDecl || []).forEach(function(oneof) { | ||
@@ -209,5 +209,5 @@ if (oneof.name) | ||
| function camelCaseField(field) { | ||
| if (field.name) | ||
| field.name = protobuf.util.camelCase(field.name); | ||
| function ensureJsonName(field) { | ||
| if (field.name && !field.jsonName) | ||
| field.jsonName = protobuf.util.jsonName(field.name); | ||
| } | ||
@@ -214,0 +214,0 @@ |
420575
0.41%9133
0.16%