MDL-67712 grunt: Ensure that more-specific matches are first
authorAndrew Nicols <andrew@nicols.co.uk>
Thu, 16 Jan 2020 13:41:17 +0000 (21:41 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Sun, 16 Feb 2020 03:03:51 +0000 (11:03 +0800)
GruntfileComponents.js

index 06ed999..54a431c 100644 (file)
@@ -163,8 +163,10 @@ const getComponentFromPath = path => {
 const getOwningComponentDirectory = checkPath => {
     const path = require('path');
 
-    const pathList = fetchComponentData().components;
-    for (const componentPath of Object.keys(pathList)) {
+    // Fetch all components into a reverse sorted array.
+    // This ensures that components which are within the directory of another component match first.
+    const pathList = Object.keys(fetchComponentData().components).sort().reverse();
+    for (const componentPath of pathList) {
         if (checkPath === componentPath) {
             return componentPath;
         }