Skip to content

Commit

Permalink
Merge pull request #1 from fluentci-io/fix/fluentci-doctor
Browse files Browse the repository at this point in the history
fix: catch all `fluentci doctor` errors
  • Loading branch information
tsirysndr authored Nov 2, 2023
2 parents e462cf8 + 506fec6 commit 0cbce2f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fluentci # Run the pipeline
fluentci --help

Usage: fluentci [pipeline] [jobs...]
Version: 0.6.7
Version: 0.6.8

Description:

Expand Down
2 changes: 1 addition & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import doctor from "./src/cmd/doctor.ts";
export async function main() {
await new Command()
.name("fluentci")
.version("0.6.7")
.version("0.6.8")
.description(
`
.
Expand Down
53 changes: 34 additions & 19 deletions src/cmd/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,21 @@ const verifyGlow = async () => {
stderr: "piped",
});

const { stdout, code } = await command.output();

if (code !== 0) {
try {
const { stdout, code } = await command.output();

if (code !== 0) {
console.log(`${red("[✗]")} Glow (not installed)`);
return false;
}

console.log(
`${green("[✓]")} Glow (${new TextDecoder().decode(stdout).trimEnd()})`
);
} catch (_) {
console.log(`${red("[✗]")} Glow (not installed)`);
return false;
}

console.log(
`${green("[✓]")} Glow (${new TextDecoder().decode(stdout).trimEnd()})`
);
return true;
};

Expand All @@ -62,17 +67,22 @@ const verifyDeno = async () => {
stderr: "piped",
});

const { stdout, code } = await command.output();
try {
const { stdout, code } = await command.output();

if (code !== 0) {
if (code !== 0) {
console.log(`${red("[✗]")} Deno (not installed)`);
return false;
}

const version = new TextDecoder().decode(stdout).split("\n")[0].trimEnd();

console.log(`${green("[✓]")} Deno (${version})`);
} catch (_) {
console.log(`${red("[✗]")} Deno (not installed)`);
return false;
}

const version = new TextDecoder().decode(stdout).split("\n")[0].trimEnd();

console.log(`${green("[✓]")} Deno (${version})`);

return true;
};

Expand All @@ -83,17 +93,22 @@ const verifyDagger = async () => {
stderr: "piped",
});

const { stdout, code } = await command.output();
try {
const { stdout, code } = await command.output();

if (code !== 0) {
if (code !== 0) {
console.log(`${red("[✗]")} Dagger (not installed)`);
return false;
}

console.log(
`${green("[✓]")} Dagger (${new TextDecoder().decode(stdout).trimEnd()})`
);
} catch (_) {
console.log(`${red("[✗]")} Dagger (not installed)`);
return false;
}

console.log(
`${green("[✓]")} Dagger (${new TextDecoder().decode(stdout).trimEnd()})`
);

return true;
};

Expand Down

0 comments on commit 0cbce2f

Please sign in to comment.