@@ -113,30 +113,29 @@
}
/**
- * Colorize the parts of a version string that are different than a given string to compare to. Assumes that the two
- * verson strings are in the same format.
+ * Colorize the parts of a version string (to) that are different than another (from). Assumes that the two verson strings are in the same format.
*/
-function colorizeDiff(strToColor, strToCompare) {
+function colorizeDiff(from, to) {
let leadingWildcard = '';
// separate out leading ^ or ~
- if (/^[~^]/.test(strToColor) && strToColor[0] === strToCompare[0]) {
- leadingWildcard = strToColor[0];
- strToColor = strToColor.slice(1);
- strToCompare = strToCompare.slice(1);
+ if (/^[~^]/.test(to) && to[0] === from[0]) {
+ leadingWildcard = to[0];
+ to = to.slice(1);
+ from = from.slice(1);
}
// split into parts
- const partsToColor = strToColor.split('.');
- const partsToCompare = strToCompare.split('.');
+ const partsToColor = to.split('.');
+ const partsToCompare = from.split('.');
let i = _.findIndex(partsToColor, (part, i) => part !== partsToCompare[i]);
i = i >= 0 ? i : partsToColor.length;
- // major = red
+ // major = red (or any change before 1.0.0)
// minor = cyan
// patch = green
- const color = i === 0 ? 'red' :
+ const color = i === 0 || partsToColor[0] === '0' ? 'red' :
i === 1 ? 'cyan' :
'green';