diff --git a/.gitignore b/.gitignore index 90dc942..e4204ce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /node_modules /yarn-error.log /dist +/config.toml diff --git a/config.toml b/config-example.toml similarity index 100% rename from config.toml rename to config-example.toml diff --git a/index.js b/index.js index bcf95fe..bc792a1 100644 --- a/index.js +++ b/index.js @@ -7,16 +7,16 @@ import { v4 as uuidv4 } from "uuid"; import express from "express"; const url_path = "/"; -const config_path = "config.toml"; const template_dir = "template/"; const template_path = "index.html.njk"; const output_path = "dist/index.html"; - +var config_path = "config.toml"; function main() { program .option("--serve", "serve the gerneated files") .option("--generate", "generate prod ready files") + .option("--config ", "config file you use, config-sample.toml as example"); program.parse(); const options = program.opts(); @@ -25,6 +25,10 @@ function main() { program.help(); } + if (options.config) { + config_path = options.config; + } + let config = fs.readFileSync(config_path, {encoding: "utf-8"}); config = toml.parse(config)