From c62848a886703069d02c1c22c4baa12c53d651d4 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Sat, 7 Dec 2019 06:55:30 +1100 Subject: [PATCH] fix bug with NpmPackage ignoring files in root of package --- .../hl7/fhir/utilities/cache/NpmPackage.java | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java index 6e2947d66..884c3b4aa 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java @@ -189,23 +189,29 @@ public class NpmPackage { File dir = new File(path); for (File f : dir.listFiles()) { - if (f.isDirectory()) { - String d = f.getName(); - if (!d.equals("package")) { - d = Utilities.path("package", d); - } - NpmPackageFolder folder = res.new NpmPackageFolder(d); - folder.folder = f; - res.folders.put(f.getName(), folder); - File ij = new File(Utilities.path(f.getAbsolutePath(), ".index.json")); - if (ij.exists()) { - try { - folder.readIndex(JsonTrackingParser.parseJson(ij)); - } catch (Exception e) { - throw new IOException("Error parsing "+ij.getAbsolutePath()+": "+e.getMessage(), e); + if (!Utilities.existsInList(f.getName(), ".git", ".svn") && !Utilities.existsInList(f.getName(), exemptions)) { + if (f.isDirectory()) { + String d = f.getName(); + if (!d.equals("package")) { + d = Utilities.path("package", d); } + NpmPackageFolder folder = res.new NpmPackageFolder(d); + folder.folder = f; + res.folders.put(f.getName(), folder); + File ij = new File(Utilities.path(f.getAbsolutePath(), ".index.json")); + if (ij.exists()) { + try { + folder.readIndex(JsonTrackingParser.parseJson(ij)); + } catch (Exception e) { + throw new IOException("Error parsing "+ij.getAbsolutePath()+": "+e.getMessage(), e); + } + } + loadSubFolders(res, dir.getAbsolutePath(), f); + } else { + NpmPackageFolder folder = res.new NpmPackageFolder("package/$root"); + folder.folder = dir; + res.folders.put("package/$root", folder); } - loadSubFolders(res, dir.getAbsolutePath(), f); } } }