add argument to specify config

This commit is contained in:
leafee98 2023-07-14 21:38:39 +08:00
parent 056ba6d410
commit 0cb17f8a89
3 changed files with 7 additions and 2 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
/node_modules
/yarn-error.log
/dist
/config.toml

View file

@ -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>", "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)