Skip to content

Commit ece50bf

Browse files
7ffbSteven0351
authored andcommitted
Added JSON configuration support (#3)
1 parent 54e8507 commit ece50bf

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

main.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,16 @@ const sliceDocumentsFromJazzyArgs = (outputArg) => {
5151

5252
const getDocumentationFolder = () => {
5353
if (configFilePath) {
54-
const config = yaml.safeLoad(fs.readFileSync(configFilePath, "utf8"))
54+
let config
55+
const fileExt = configFilePath.split(".").pop().toLowerCase()
56+
57+
if (fileExt === "yml" || fileExt === "yaml") {
58+
config = yaml.safeLoad(fs.readFileSync(configFilePath, "utf8"))
59+
} else if (fileExt === "json") {
60+
const rawData = fs.readFileSync(configFilePath)
61+
config = JSON.parse(rawData)
62+
}
63+
5564
if (config.output) {
5665
return config.output
5766
}

0 commit comments

Comments
 (0)