Skip to content

Commit

Permalink
style: updated logic to determine default config (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
aemmadi committed Aug 19, 2020
1 parent ab32a70 commit eea68ff
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions util.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ function isDiffReadme(user, repo, readmeData) {
// Writes all the required files
async function writeDocs(user, repo, readmeData) {
const config = await getConfig(user, repo);

if (isConfigDefault(config)) {
writeDocsWithDefaultConfig(user, repo, readmeData);
} else {
// TODO: if config is not default? --> plugin integration!!!
if (config) {
writeDocsWithConfig(user, repo, readmeData, config);
} else {
writeDocsWithDefaultConfig(user, repo, readmeData);
}
}

Expand Down Expand Up @@ -119,11 +117,6 @@ function serveDocs(app, user, repo) {
app.use(`/${user}/${repo}`, express.static(`./docs/${user}-${repo}`));
}

function isConfigDefault(config) {
if (config.name != "") return false;
return true;
}

async function getConfig(user, repo) {
const gitRepo = await axios.get(
`https://api.github.com/repos/${user}/${repo}/contents`
Expand All @@ -142,7 +135,7 @@ async function getConfig(user, repo) {
const config = await axios.get(configUrl);
return config.data;
}
return mainConfig;
return "";
}

async function compileDocs(user, repo) {
Expand Down

0 comments on commit eea68ff

Please sign in to comment.