Skip to content

Commit

Permalink
Optional config.
Browse files Browse the repository at this point in the history
  • Loading branch information
lumenwrites committed May 16, 2023
1 parent 6845554 commit 1dbe0c0
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import matter from 'gray-matter'
import { copyFiles, readText, saveText, ensureDirExists, readJson, saveJson } from './utils'
import { zip } from 'zip-a-folder'

const WORKING_DIR = process.cwd() + '/godot-node-essentials' // + `/learn-to-code-from-zero-test`
const WORKING_DIR = process.cwd() // + '/godot-node-essentials' // + `/learn-to-code-from-zero-test`
const CONTENT_DIR = `${WORKING_DIR}/content-gdschool`
const OUTPUT_DIR = `${WORKING_DIR}/content-gdschool-processed`
const RELEASES_DIR = `${WORKING_DIR}/content-gdschool-releases`
let config = readText(`${WORKING_DIR}/course.cfg`)
config = config ? parseConfig(config) : {}
let config


async function main() {
loadConfig()
let courseIndexText = readText(`${CONTENT_DIR}/_index.md`)
const { data: courseFrontmatter } = matter(courseIndexText)
// Copy all files to the output folder
Expand Down Expand Up @@ -238,6 +239,15 @@ function searchFiles(currentPath, callback) {
}
}

function loadConfig() {
try {
config = readText(`${WORKING_DIR}/course.cfg`)
} catch (e) {
console.log('No course.cfg file found in the course directory.')
}
config = config ? parseConfig(config) : {}
}

function getDate() {
const today = new Date()
const year = today.getFullYear()
Expand Down

0 comments on commit 1dbe0c0

Please sign in to comment.