Skip to content

Commit

Permalink
fix!: exit from CLI with non-zero exit code when no result
Browse files Browse the repository at this point in the history
  • Loading branch information
broofa committed Sep 13, 2023
1 parent 28784aa commit 356004c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/mime_cli.ts
Expand Up @@ -65,12 +65,17 @@ export default async function () {
} else if (args.includes('--reverse') || args.includes('-r')) {
const mimeType = args[args.length - 1];
const extension = mime.getExtension(mimeType);

if (!extension) process.exit(1);

process.stdout.write(extension + '\n');
process.exit(0);
}

const file = args[0];
const type = mime.getType(file);

if (!type) process.exit(1);

process.stdout.write(type + '\n');
}

0 comments on commit 356004c

Please sign in to comment.