Skip to content

Commit f22a34a

Browse files
committed
Other: Updated tests for new package.json layout; Other: Added break/continue label support to codegen
1 parent e88d13c commit f22a34a

File tree

5 files changed

+51
-5
lines changed

5 files changed

+51
-5
lines changed

package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"dependencies": {
4545
"@protobufjs/aspromise": "^1.0.5",
4646
"@protobufjs/base64": "^1.0.5",
47-
"@protobufjs/codegen": "^1.0.4",
47+
"@protobufjs/codegen": "^1.0.5",
4848
"@protobufjs/eventemitter": "^1.0.5",
4949
"@protobufjs/extend": "^1.0.2",
5050
"@protobufjs/fetch": "^1.0.4",
@@ -89,5 +89,12 @@
8989
"zuul": "^3.11.1",
9090
"zuul-ngrok": "^4.0.0"
9191
},
92-
"cliDependencies": [ "chalk", "glob", "jsdoc", "minimist", "tmp", "uglify-js" ]
92+
"cliDependencies": [
93+
"chalk",
94+
"glob",
95+
"jsdoc",
96+
"minimist",
97+
"tmp",
98+
"uglify-js"
99+
]
93100
}

src/util/codegen/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var blockOpenRe = /[{[]$/,
55
blockCloseRe = /^[}\]]/,
66
casingRe = /:$/,
77
branchRe = /^\s*(?:if|}?else if|while|for)\b|\b(?:else)\s*$/,
8-
breakRe = /\b(?:break|continue);?$|^\s*return\b/;
8+
breakRe = /\b(?:break|continue)(?: \w+)?;?$|^\s*return\b/;
99

1010
/**
1111
* A closure for generating functions programmatically.

src/util/codegen/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@protobufjs/codegen",
33
"description": "A closure for generating functions programmatically.",
4-
"version": "1.0.4",
4+
"version": "1.0.5",
55
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
66
"repository": {
77
"type": "git",

tests/data/package.js

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,14 @@ $root.Package = (function() {
124124
*/
125125
$prototype.types = "";
126126

127+
/**
128+
* Package cliDependencies.
129+
* @type {Array.<string>}
130+
*/
131+
$prototype.cliDependencies = $protobuf.util.emptyArray;
132+
127133
// Referenced types
128-
var $types = [null, null, null, null, null, "Package.Repository", null, null, null, null, null, null, null, null, null, null]; $lazyTypes.push($types);
134+
var $types = [null, null, null, null, null, "Package.Repository", null, null, null, null, null, null, null, null, null, null, null]; $lazyTypes.push($types);
129135

130136
/**
131137
* Creates a new Package instance using the specified properties.
@@ -207,6 +213,11 @@ $root.Package = (function() {
207213
if (message.types !== undefined && message.types !== "") {
208214
writer.uint32(138).string(message.types);
209215
}
216+
if (message.cliDependencies) {
217+
for (var i = 0; i < message.cliDependencies.length; ++i) {
218+
writer.uint32(146).string(message.cliDependencies[i]);
219+
}
220+
}
210221
return writer;
211222
};})($protobuf.Writer, $protobuf.util, $types);
212223

@@ -347,6 +358,13 @@ $root.Package = (function() {
347358
message.types = reader.string();
348359
break;
349360

361+
case 18:
362+
if (!(message.cliDependencies && message.cliDependencies.length)) {
363+
message.cliDependencies = [];
364+
}
365+
message.cliDependencies.push(reader.string());
366+
break;
367+
350368
default:
351369
reader.skipType(tag & 7);
352370
break;
@@ -488,6 +506,16 @@ $root.Package = (function() {
488506
return "Package.types: string expected";
489507
}
490508
}
509+
if (message.cliDependencies !== undefined) {
510+
if (!Array.isArray(message.cliDependencies)) {
511+
return "Package.cliDependencies: array expected";
512+
}
513+
for (var i = 0; i < message.cliDependencies.length; ++i) {
514+
if (!util.isString(message.cliDependencies[i])) {
515+
return "Package.cliDependencies: string[] expected";
516+
}
517+
}
518+
}
491519
return null;
492520
};})($protobuf.util, $types);
493521

@@ -560,6 +588,16 @@ $root.Package = (function() {
560588
if (dst.types === undefined && options.defaults) {
561589
dst.types = "";
562590
}
591+
if (src.cliDependencies && src.cliDependencies.length) {
592+
dst.cliDependencies = [];
593+
for (var i = 0; i < src.cliDependencies.length; ++i) {
594+
dst.cliDependencies.push(src.cliDependencies[i]);
595+
}
596+
} else {
597+
if (options.defaults || options.arrays) {
598+
dst.cliDependencies = [];
599+
}
600+
}
563601
}
564602
return dst;
565603
};})($types);

tests/data/package.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ message Package {
2424
map<string, string> devDependencies = 15;
2525
// map<string, bool> browser = 16;
2626
string types = 17;
27+
repeated string cliDependencies = 18;
2728
}

0 commit comments

Comments
 (0)