Skip to content

Commit ac06772

Browse files
committed
Add a script to convert the Vue.js dev runtime source to Java Strings
1 parent 642d358 commit ac06772

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

utils/processVueDevRuntime.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Process the Vue.js dev runtime and output lines of java
3+
* to be put in VueLibDevInjector
4+
*/
5+
6+
const fs = require('fs');
7+
8+
const JAVA_STRING_LIMIT = 65535;
9+
10+
fs.readFile('vue.runtime.js', 'utf8', function(err, data) {
11+
if (err) throw err;
12+
data = data.replace(/\\/g, "\\\\").replace(/\n/g, "\\n").replace(/"/g, "\\\"");
13+
14+
console.log(`StringBuilder builder = new StringBuilder();`)
15+
while (data.length > JAVA_STRING_LIMIT) {
16+
addToStringBuilder(data.substring(0, JAVA_STRING_LIMIT));
17+
data = data.substring(JAVA_STRING_LIMIT);
18+
}
19+
addToStringBuilder(data);
20+
});
21+
22+
function addToStringBuilder(string) {
23+
console.log(`builder.append("${string}");`);
24+
}

0 commit comments

Comments
 (0)