about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2020-03-21 13:48:10 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2020-03-21 13:48:10 +0100
commit2b4feba18f390501b97d6fc36dc34d6f9ca8cb04 (patch)
treea9ad302918cbd6e65fd08d85e190ededab585237 /src
parentfeb6635fe66acefb8dbde13a47a7e8d88bbd0d42 (diff)
downloadrust-2b4feba18f390501b97d6fc36dc34d6f9ca8cb04.tar.gz
rust-2b4feba18f390501b97d6fc36dc34d6f9ca8cb04.zip
Pick the last version of the different files if there is more than one
Diffstat (limited to 'src')
-rw-r--r--src/tools/rustdoc-js-std/tester.js24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/tools/rustdoc-js-std/tester.js b/src/tools/rustdoc-js-std/tester.js
index f34e702e85e..affdcc7f4b7 100644
--- a/src/tools/rustdoc-js-std/tester.js
+++ b/src/tools/rustdoc-js-std/tester.js
@@ -2,8 +2,10 @@ const fs = require('fs');
 const path = require('path');
 const tools = require('../rustdoc-js-common/lib.js');
 
+
 function findFile(dir, name, extension) {
     var entries = fs.readdirSync(dir);
+    var matches = [];
     for (var i = 0; i < entries.length; ++i) {
         var entry = entries[i];
         var file_type = fs.statSync(dir + entry);
@@ -11,10 +13,28 @@ function findFile(dir, name, extension) {
             continue;
         }
         if (entry.startsWith(name) && entry.endsWith(extension)) {
-            return entry;
+            var version = entry.slice(name.length, entry.length - extension.length);
+            version = version.split(".").map(function(x) {
+                return parseInt(x);
+            });
+            var total = 0;
+            var mult = 1;
+            for (var j = version.length - 1; j >= 0; --j) {
+                total += version[j] * mult;
+                mult *= 1000;
+            }
+            matches.push([entry, total]);
         }
     }
-    return null;
+    if (matches.length === 0) {
+        return null;
+    }
+    // We make a reverse sort to have the "highest" file. Very useful in case you didn't clean up
+    // you std doc folder...
+    matches.sort(function(a, b) {
+        return b[1] - a[1];
+    });
+    return matches[0][0];
 }
 
 function readFileMatching(dir, name, extension) {