-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring config parsing module and index.ts
- clean up whitespace - move TOML example to examples folder - store command line arguments in object - removed version & help switches in example toml - refactored config parser module - changed output directory in example toml - added -c usage to documentation - removed unnecessary package-lock file
- Loading branch information
Showing
10 changed files
with
81 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# TOML sample configuration file | ||
|
||
# Set input directory | ||
target = "./examples/dir" | ||
|
||
# Output directory where generated files will be saved | ||
output = "./til" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import toml from "toml"; | ||
|
||
export default async function parseConfig(configPath: string) { | ||
const file = Bun.file(configPath); | ||
const fileExists = await file.exists(); | ||
if (!fileExists) { | ||
throw new Error(`Configuration file not found at '${configPath}'.`); | ||
} | ||
|
||
try { | ||
const configString = await file.text(); | ||
return toml.parse(configString); | ||
} catch (err) { | ||
throw new Error(`Error reading or parsing TOML file.`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters