Skip to content

Commit

Permalink
fix: check stderr for null
Browse files Browse the repository at this point in the history
  • Loading branch information
Silthus committed Sep 29, 2021
1 parent e3656e1 commit 53ebd04
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/gradle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ export function getTaskToPublish(
env,
stdio: ["inherit", "pipe"],
});
if (child.stdout === null) {
reject(new Error("Unexpected error: stdout of subprocess is null"));
if (child.stdout === null || child.stderr == null) {
reject(
new Error("Unexpected error: stdout or stderr of subprocess is null")
);
} else {
let task = "";
child.stdout.setEncoding('utf8');
child.stdout.setEncoding("utf8");
child.stdout.pipe(split()).on("data", (line: string) => {
if (line.startsWith("artifactoryDeploy -")) {
// Plugins Gradle Artifactory Plugin and Maven Publish Plugin are often used together
Expand All @@ -63,7 +65,11 @@ export function getTaskToPublish(
task = "artifactoryDeploy";
} else if (line.startsWith("publish -")) {
// Plugins Gradle Artifactory Plugin and Maven Publish Plugin are often used together
if (task !== "" && task !== "artifactoryDeploy" && task !== "publishPlugins") {
if (
task !== "" &&
task !== "artifactoryDeploy" &&
task !== "publishPlugins"
) {
reject(new Error(ERROR_MULTIPLE_PLUGIN));
}
if (task === "artifactoryDeploy") {
Expand All @@ -88,9 +94,9 @@ export function getTaskToPublish(
}
logger.debug(line);
});
child.stderr.setEncoding('utf8');
child.stderr.setEncoding("utf8");
child.stderr.pipe(split()).on("data", (line: string) => {
logger.error(line)
logger.error(line);
});
child.on("close", (code: number) => {
if (code !== 0) {
Expand Down

0 comments on commit 53ebd04

Please sign in to comment.