refactor(dart): Pub deps extractor reads lines.
package com.synopsys.integration.detectable.detectables.dart.pubdep;
import java.io.File;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@@ -22,11 +24,11 @@ import com.synopsys.integration.executable.ExecutableRunnerException;
import com.synopsys.integration.util.NameVersion;
public class PubDepsExtractor {
- private Logger logger = LoggerFactory.getLogger(this.getClass());
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final DetectableExecutableRunner executableRunner;
private final PubDepsParser pubDepsParser;
- private PubSpecYamlNameVersionParser nameVersionParser;
+ private final PubSpecYamlNameVersionParser nameVersionParser;
private final ToolVersionLogger toolVersionLogger;
public PubDepsExtractor(
@@ -75,7 +77,11 @@ public class PubDepsExtractor {
}
}
- Optional<NameVersion> nameVersion = nameVersionParser.parseNameVersion(pubSpecYamlFile);
+ Optional<NameVersion> nameVersion = Optional.empty();
+ if (pubSpecYamlFile != null) {
+ List<String> pubSpecYamlLines = Files.readAllLines(pubSpecYamlFile.toPath(), StandardCharsets.UTF_8);
+ nameVersion = nameVersionParser.parseNameVersion(pubSpecYamlLines);
+ }
DependencyGraph dependencyGraph = pubDepsParser.parse(pubDepsOutput.getStandardOutputAsList());
