Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added functionality for config file #39

Merged
merged 4 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ ssgy -i examples
14. adding -s stylesheet option
15. making it easy on the eyes =) checkout my cmd-ssg -h
16. proper error message if incorrect file/folder inputs
17. accept a json file to pass options from the file

```
Special Thanks : Kevan Yang
Expand Down
11 changes: 10 additions & 1 deletion bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ let outputFolder = "./dist";

//commander
const { program } = require("commander");
const { option } = require("yargs");
program.version("0.1");
program.option("-c, --config <type>", "enter the config.json file with options to be added here")
program.option("-v, --version", "version 0.1");
program.option("-h, --help", "help for cmd-svg");
program.option("-i, --input <input>", "specify input file or folder");
Expand Down Expand Up @@ -360,6 +362,13 @@ if (options.version) {
} else {
//yargs
//check if input is file or folder and if it exists
if(options.config){
const configFile = require("../"+options.config);
configFile.input ? options.input = configFile.input : process.exit(1);
configFile.stylesheet ? options.stylesheet = configFile.stylesheet : options.stylesheet = undefined;
}


let files = [];

if (process.argv[5] != undefined){
Expand All @@ -375,7 +384,7 @@ if (options.version) {
//do the magic of converting txt to html
console.log(` running >>>`);

convertToHtml(process.argv[3], options.stylesheet, outputFolder, isFile);
convertToHtml(options.input, options.stylesheet, outputFolder, isFile);
} else {
//no input given
console.log(errorCode1);
Expand Down