Skip to content

Commit

Permalink
Merge pull request #12 from tjsr/refactor/util-modules
Browse files Browse the repository at this point in the history
Refactor to split out util functions.
  • Loading branch information
tjsr committed Jul 9, 2024
2 parents 61fcac7 + 43763a3 commit 822840a
Show file tree
Hide file tree
Showing 15 changed files with 1,947 additions and 140 deletions.
10 changes: 10 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import tjsrEslintConfig from '@tjsr/eslint-config';
import tseslint from 'typescript-eslint';

export default tseslint.config({
extends: [
...tjsrEslintConfig,
],
files: ["**/*.ts"],
ignores: ["dist/**"],
});
10 changes: 6 additions & 4 deletions girt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ program
.option("-t, --token <token>", "GitHub token")
.action(async (_option, command) => {
console.log(program.description());
const commandList = program.commands.filter((command) => command.name() !== 'girt').map((command) => ` ${command.name()}: ${command.description()}`).join('\n');
const commandList = program.commands.filter(
(command) => command.name() !== 'girt')
.map((command) => ` ${command.name()}: ${command.description()}`).join('\n');
console.log(commandList);
command.outputHelp();
});

program.addCommand(protectCommand());
program.addCommand(loginCommand());
program.addCommand(tokenCommand());
program.addCommand(protectCommand());
program.addCommand(loginCommand());
program.addCommand(tokenCommand());

await program.parseAsync(process.argv);
10 changes: 7 additions & 3 deletions login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ export const loginCommand = ():commander.Command => {
token = await getAuthTokenAsString();
if (token) {
command.error('Token already set. Skipping login. Use \'-s\' switch to skip token check.',
{ exitCode: 5, code: 'girt.login.token_already_set' })
{ code: 'girt.login.token_already_set', exitCode: 5 });
return;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
command.error('Failed executing `gh auth token` command. ' + err.message, { exitCode: 3, code: 'girt.login.token_cmd_failed' });
command.error('Failed executing `gh auth token` command. ' +
err.message, { code: 'girt.login.token_cmd_failed', exitCode: 3 });
}
}

Expand All @@ -32,8 +34,10 @@ export const loginCommand = ():commander.Command => {
console.log(token);
return;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
command.error('Failed executing `gh auth token` command. ' + err.message, { exitCode: 3, code: 'girt.login.token_cmd_failed' });
command.error('Failed executing `gh auth token` command. ' +
err.message, { code: 'girt.login.token_cmd_failed', exitCode: 3 });
}
});
return login;
Expand Down
Loading

0 comments on commit 822840a

Please sign in to comment.