@@ -331,6 +331,7 @@ public JsonObject oidIndex() throws IOException {
331
331
332
332
}
333
333
334
+
334
335
private String path ;
335
336
private JsonObject npm ;
336
337
private Map <String , NpmPackageFolder > folders = new HashMap <>();
@@ -339,6 +340,7 @@ public JsonObject oidIndex() throws IOException {
339
340
private boolean minimalMemory ;
340
341
private int size ;
341
342
private boolean warned = false ;
343
+ private static boolean loadCustomResources ;
342
344
343
345
/**
344
346
* Constructor
@@ -406,7 +408,7 @@ public Map<String, Object> getUserData() {
406
408
public void loadFiles (String path , File source , String ... exemptions ) throws FileNotFoundException , IOException {
407
409
this .npm = JsonParser .parseObject (TextFile .fileToString (Utilities .path (path , "package" , "package.json" )));
408
410
this .path = path ;
409
-
411
+
410
412
File dir = ManagedFileAccess .file (path );
411
413
for (File f : dir .listFiles ()) {
412
414
if (!isInternalExemptFile (f ) && !Utilities .existsInList (f .getName (), exemptions )) {
@@ -431,6 +433,7 @@ public void loadFiles(String path, File source, String... exemptions) throws Fil
431
433
}
432
434
}
433
435
loadSubFolders (dir .getAbsolutePath (), f );
436
+
434
437
} else {
435
438
NpmPackageFolder folder = this .new NpmPackageFolder (Utilities .path ("package" , "$root" ));
436
439
folder .folder = dir ;
@@ -448,24 +451,26 @@ public static boolean isInternalExemptFile(File f) {
448
451
private void loadSubFolders (String rootPath , File dir ) throws IOException {
449
452
for (File f : dir .listFiles ()) {
450
453
if (f .isDirectory ()) {
451
- String d = f .getAbsolutePath ().substring (rootPath .length ()+1 );
452
- if (!d .startsWith ("package" )) {
453
- d = Utilities .path ("package" , d );
454
- }
455
- NpmPackageFolder folder = this .new NpmPackageFolder (d );
456
- folder .folder = f ;
457
- this .folders .put (d , folder );
458
- File ij = ManagedFileAccess .file (Utilities .path (f .getAbsolutePath (), ".index.json" ));
459
- if (ij .exists () || !minimalMemory ) {
460
- try {
461
- if (!ij .exists () || !folder .readIndex (JsonParser .parseObject (ij ), folder .getTypes ())) {
462
- indexFolder (folder .getFolderName (), folder );
454
+ if (!"custom" .equals (f .getName ()) || loadCustomResources ) {
455
+ String d = f .getAbsolutePath ().substring (rootPath .length ()+1 );
456
+ if (!d .startsWith ("package" )) {
457
+ d = Utilities .path ("package" , d );
458
+ }
459
+ NpmPackageFolder folder = this .new NpmPackageFolder (d );
460
+ folder .folder = f ;
461
+ this .folders .put (d , folder );
462
+ File ij = ManagedFileAccess .file (Utilities .path (f .getAbsolutePath (), ".index.json" ));
463
+ if (ij .exists () || !minimalMemory ) {
464
+ try {
465
+ if (!ij .exists () || !folder .readIndex (JsonParser .parseObject (ij ), folder .getTypes ())) {
466
+ indexFolder (folder .getFolderName (), folder );
467
+ }
468
+ } catch (Exception e ) {
469
+ throw new IOException ("Error parsing " +ij .getAbsolutePath ()+": " +e .getMessage (), e );
463
470
}
464
- } catch (Exception e ) {
465
- throw new IOException ("Error parsing " +ij .getAbsolutePath ()+": " +e .getMessage (), e );
466
471
}
472
+ loadSubFolders (rootPath , f );
467
473
}
468
- loadSubFolders (rootPath , f );
469
474
}
470
475
}
471
476
}
@@ -1510,5 +1515,12 @@ public String vid() {
1510
1515
return id ()+"#" +version ();
1511
1516
}
1512
1517
1513
-
1518
+ public static boolean isLoadCustomResources () {
1519
+ return loadCustomResources ;
1520
+ }
1521
+
1522
+ public static void setLoadCustomResources (boolean loadCustomResources ) {
1523
+ NpmPackage .loadCustomResources = loadCustomResources ;
1524
+ }
1525
+
1514
1526
}
0 commit comments