add argument to specify config
This commit is contained in:
parent
056ba6d410
commit
0cb17f8a89
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
/node_modules
|
||||
/yarn-error.log
|
||||
/dist
|
||||
/config.toml
|
||||
|
|
8
index.js
8
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>", "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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue