Skip to content

Commit

Permalink
serializePlaceholders: attempt to workaround stupid Windows shell bug
Browse files Browse the repository at this point in the history
  • Loading branch information
evocateur committed May 1, 2017
1 parent 1e524a1 commit 9a7cfd1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/helpers/serializePlaceholders.js
Expand Up @@ -6,21 +6,29 @@ const _ = require("lodash");
const normalizeNewline = require("normalize-newline");
const constants = require("./constants");

const VERSION_REGEX = new RegExp(`v?${constants.LERNA_VERSION}`, "gm");
const NO_TEST_ERROR = /'(Error: no test specified)'/g;
const VERSION_REGEX = new RegExp(`v?${constants.LERNA_VERSION}`, "g");
// TODO: maybe less naïve regex?

function needsReplacement(str) {
return (
str.indexOf(constants.__TEST_VERSION__) === -1
str.indexOf(constants.__TEST_VERSION__) === -1 ||
NO_TEST_ERROR.test(str)
);
}

// Windows has an annoying habit of quoting the entire message
function stableTestError(str) {
return str.replace(NO_TEST_ERROR, "$1");
}

function stableVersion(str) {
return str.replace(VERSION_REGEX, constants.__TEST_VERSION__);
}

const stabilizeString = _.flow([
normalizeNewline,
stableTestError,
stableVersion,
]);

Expand Down

0 comments on commit 9a7cfd1

Please sign in to comment.