From 05a46ddb4c78df8d9118600b5d60d32f7fcd130c Mon Sep 17 00:00:00 2001
From: Jamie Magee <JamieMagee@users.noreply.github.com>
Date: Tue, 16 Apr 2019 16:03:37 +0200
Subject: [PATCH] fix: nodejs 11 support (#3549)

Due to an update in the v8 runtime, Node.js `Array.prototype.sort()` is now stable (See [here](https://github.com/nodejs/node/pull/22754#issuecomment-423452575)).

These changes allow for tests to pass on both Node.js 10 and 11.

Fixes #3445
---
 .travis.yml                                       | 3 ++-
 lib/config/validation.js                          | 4 ++--
 lib/versioning/ruby/index.js                      | 2 +-
 package.json                                      | 2 +-
 test/config/__snapshots__/validation.spec.js.snap | 8 ++++----
 5 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index f270c136c9..f26ab4e506 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,7 +4,8 @@ notifications:
 language: node_js
 
 node_js:
-  - '10.15.0'
+  - 'lts/dubnium'
+  - '11'
 
 sudo: false
 
diff --git a/lib/config/validation.js b/lib/config/validation.js
index c177fc1dd5..e542bedba3 100644
--- a/lib/config/validation.js
+++ b/lib/config/validation.js
@@ -283,10 +283,10 @@ async function validateConfig(config, isPreset, parentPath) {
   }
   function sortAll(a, b) {
     if (a.depName === b.depName) {
-      return a.message > b.message;
+      return a.message > b.message ? 1 : -1;
     }
     // istanbul ignore next
-    return a.depName > b.depName;
+    return a.depName > b.depName ? 1 : -1;
   }
   errors.sort(sortAll);
   warnings.sort(sortAll);
diff --git a/lib/versioning/ruby/index.js b/lib/versioning/ruby/index.js
index 3daecc2cce..d65d338d3c 100644
--- a/lib/versioning/ruby/index.js
+++ b/lib/versioning/ruby/index.js
@@ -65,7 +65,7 @@ const getNewValue = (currentValue, rangeStrategy, fromVersion, toVersion) => {
   }
 };
 
-const sortVersions = (left, right) => gt(left, right);
+const sortVersions = (left, right) => (gt(left, right) ? 1 : -1);
 
 module.exports = {
   equals,
diff --git a/package.json b/package.json
index 678e4c8493..a1c5b2f2fc 100644
--- a/package.json
+++ b/package.json
@@ -77,7 +77,7 @@
   },
   "homepage": "https://renovatebot.com",
   "engines": {
-    "node": "^10.13.0"
+    "node": "^10.13.0 || ^11.0.0"
   },
   "dependencies": {
     "@renovate/pep440": "0.4.1",
diff --git a/test/config/__snapshots__/validation.spec.js.snap b/test/config/__snapshots__/validation.spec.js.snap
index ae99ed5195..f12b690515 100644
--- a/test/config/__snapshots__/validation.spec.js.snap
+++ b/test/config/__snapshots__/validation.spec.js.snap
@@ -2,10 +2,6 @@
 
 exports[`config/validation validateConfig(config) errors for all types 1`] = `
 Array [
-  Object {
-    "depName": "Configuration Error",
-    "message": "extends: Invalid timezone: Europe/Brussel",
-  },
   Object {
     "depName": "Configuration Error",
     "message": "Configuration option \`enabled\` should be boolean. Found: 1 (number)",
@@ -38,6 +34,10 @@ Array [
     "depName": "Configuration Error",
     "message": "Invalid schedule: \`Schedule \\"every 15 mins every weekday\\" should not specify minutes\`",
   },
+  Object {
+    "depName": "Configuration Error",
+    "message": "extends: Invalid timezone: Europe/Brussel",
+  },
   Object {
     "depName": "Configuration Error",
     "message": "packageRules must contain JSON objects",
-- 
GitLab