Avoid the preprocess
-function adding consecutive blank lines
When pre-processor blocks are being removed, since they don't apply to the current build target, we may currently end up with consecutive blank lines. While this is obviously not a big issue, it's nonetheless undesirable and we can adjust the `writeLine` function to prevent that.
This commit is contained in:
parent
9ceceaeeb5
commit
ec6575db00
8
external/builder/builder.js
vendored
8
external/builder/builder.js
vendored
@ -4,6 +4,8 @@ const fs = require("fs"),
|
|||||||
path = require("path"),
|
path = require("path"),
|
||||||
vm = require("vm");
|
vm = require("vm");
|
||||||
|
|
||||||
|
const AllWhitespaceRegexp = /^\s+$/g;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple preprocessor that is based on the Firefox preprocessor
|
* A simple preprocessor that is based on the Firefox preprocessor
|
||||||
* (https://dxr.mozilla.org/mozilla-central/source/build/docs/preprocessor.rst).
|
* (https://dxr.mozilla.org/mozilla-central/source/build/docs/preprocessor.rst).
|
||||||
@ -69,6 +71,12 @@ function preprocess(inFilename, outFilename, defines) {
|
|||||||
typeof outFilename === "function"
|
typeof outFilename === "function"
|
||||||
? outFilename
|
? outFilename
|
||||||
: function (line) {
|
: function (line) {
|
||||||
|
if (!line || AllWhitespaceRegexp.test(line)) {
|
||||||
|
const prevLine = out[out.length - 1];
|
||||||
|
if (!prevLine || AllWhitespaceRegexp.test(prevLine)) {
|
||||||
|
return; // Avoid adding consecutive blank lines.
|
||||||
|
}
|
||||||
|
}
|
||||||
out.push(line);
|
out.push(line);
|
||||||
};
|
};
|
||||||
function evaluateCondition(code) {
|
function evaluateCondition(code) {
|
||||||
|
Loading…
Reference in New Issue
Block a user