Skip to content

Commit

Permalink
feat: Make config file argument optional
Browse files Browse the repository at this point in the history
Config file default to config.json if argument is left empty.
  • Loading branch information
schw4rzlicht committed Jun 5, 2020
1 parent 4531c0a commit 919f9c1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ To run `twitch2ma`, just run the following command. Please be aware that you nee
network, reachable under the IP adress you configured. You also have to have telnet turned on.

```bash
twitch2ma <pathToConfigFile.json>
twitch2ma [configFile]
```

`configFile` is optional and defaults to `config.json`.

## Contribution

If you have any issues, bugs, questions or want to contribute in any way, feel free to open an issue or a pull request.
6 changes: 4 additions & 2 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ program

function main(configFile: string) {

if (!_.isString(configFile)) {
exitWithError(new Error("No config file specified!"));
let configFileIsDefault = !_.isString(configFile);

if (configFileIsDefault) {
configFile = "config.json";
}

let jsonObject = failOnErrorOrReturnValue(_.attempt(() => JSON.parse(Fs.readFileSync(configFile, {encoding: "utf-8"}))),
Expand Down

0 comments on commit 919f9c1

Please sign in to comment.