Merge branch 'pr_2498' into dev

This commit is contained in:
Nick O'Leary
2020-05-22 15:22:12 +01:00
10 changed files with 396 additions and 98 deletions

View File

@@ -25,6 +25,18 @@ var settings;
var libDir;
var libFlowsDir;
function toSingleLine(text) {
var result = text.replace(/\\/g, "\\\\").replace(/\n/g, "\\n");
return result;
}
function fromSingleLine(text) {
var result = text.replace(/\\[\\n]/g, function(s) {
return ((s === "\\\\") ? "\\" : "\n");
});
return result;
}
function getFileMeta(root, path) {
var fn = fspath.join(root, path);
var fd = fs.openSync(fn, 'r');
@@ -43,7 +55,7 @@ function getFileMeta(root, path) {
for (var i = 0; i < parts.length; i++) {
var match = /^\/\/ (\w+): (.*)/.exec(parts[i]);
if (match) {
meta[match[1]] = match[2];
meta[match[1]] = fromSingleLine(match[2]);
} else {
read = size;
break;
@@ -153,7 +165,7 @@ module.exports = {
var headers = "";
for (var i in meta) {
if (meta.hasOwnProperty(i)) {
headers += "// "+i+": "+meta[i]+"\n";
headers += "// "+i+": "+toSingleLine(meta[i])+"\n";
}
}
if (type === "flows" && settings.flowFilePretty) {