@Test public void testPackageJsonPathDeterminations() { assertThat(underTest.isPackageJson(makeEntry("package/package.json", false)), is(true)); assertThat(underTest.isPackageJson(makeEntry("foo/package.json", false)), is(true)); assertThat(underTest.isPackageJson(makeEntry("package.json", false)), is(false)); assertThat(underTest.isPackageJson(makeEntry("/package.json", false)), is(false)); assertThat(underTest.isPackageJson(makeEntry("/foo/bar/package.json", false)), is(false)); assertThat(underTest.isPackageJson(makeEntry("/foo/bar/baz/package.json", false)), is(false)); assertThat(underTest.isPackageJson(makeEntry("package/package.json", true)), is(false)); }
@VisibleForTesting boolean isPackageJson(final ArchiveEntry entry) { if (entry.isDirectory()) { return false; } String name = entry.getName(); if (name == null) { return false; } else if (!name.endsWith(PACKAGE_JSON_SUBPATH)) { return false; } else if (name.startsWith(PACKAGE_JSON_SUBPATH)) { return false; } else { return name.indexOf(PACKAGE_JSON_SUBPATH) == name.indexOf(SEPARATOR); } }
NpmPackageParser extends ComponentSupport { @VisibleForTesting boolean isPackageJson(final ArchiveEntry entry) { if (entry.isDirectory()) { return false; } String name = entry.getName(); if (name == null) { return false; } else if (!name.endsWith(PACKAGE_JSON_SUBPATH)) { return false; } else if (name.startsWith(PACKAGE_JSON_SUBPATH)) { return false; } else { return name.indexOf(PACKAGE_JSON_SUBPATH) == name.indexOf(SEPARATOR); } } }
NpmPackageParser extends ComponentSupport { @VisibleForTesting boolean isPackageJson(final ArchiveEntry entry) { if (entry.isDirectory()) { return false; } String name = entry.getName(); if (name == null) { return false; } else if (!name.endsWith(PACKAGE_JSON_SUBPATH)) { return false; } else if (name.startsWith(PACKAGE_JSON_SUBPATH)) { return false; } else { return name.indexOf(PACKAGE_JSON_SUBPATH) == name.indexOf(SEPARATOR); } }  }
NpmPackageParser extends ComponentSupport { @VisibleForTesting boolean isPackageJson(final ArchiveEntry entry) { if (entry.isDirectory()) { return false; } String name = entry.getName(); if (name == null) { return false; } else if (!name.endsWith(PACKAGE_JSON_SUBPATH)) { return false; } else if (name.startsWith(PACKAGE_JSON_SUBPATH)) { return false; } else { return name.indexOf(PACKAGE_JSON_SUBPATH) == name.indexOf(SEPARATOR); } }  Map<String, Object> parsePackageJson(final Supplier<InputStream> supplier); }
NpmPackageParser extends ComponentSupport { @VisibleForTesting boolean isPackageJson(final ArchiveEntry entry) { if (entry.isDirectory()) { return false; } String name = entry.getName(); if (name == null) { return false; } else if (!name.endsWith(PACKAGE_JSON_SUBPATH)) { return false; } else if (name.startsWith(PACKAGE_JSON_SUBPATH)) { return false; } else { return name.indexOf(PACKAGE_JSON_SUBPATH) == name.indexOf(SEPARATOR); } }  Map<String, Object> parsePackageJson(final Supplier<InputStream> supplier);  }