diff --git a/.gitgo b/.gitgo index 4933d3a..ea16922 100644 --- a/.gitgo +++ b/.gitgo @@ -1,18 +1,18 @@ { "current_issue": { - "number": "51", + "number": "53", "labels": [ "cli", - "command", "enhancement" ], - "title": "Add a command to give summary of all instructions" + "title": "Empty specific attributes from .gitgo before pushing it on github" }, "commit_guidelines": [ - "cli:" + "cli:", + "general:" ], "custom_guidelines": true, - "selected_commit_type": "✨ Adding a new user-facing feature", + "selected_commit_type": "🚀 Improving dev tools", "emojis": { "initial_commit": "tada", "feature": "sparkles", @@ -31,11 +31,13 @@ "wip": "construction" }, "existing_branches": [ + "command-summary-instructions", "main" ], "current_branch": [ - "command-summary-instructions" + "Empty-attributes-github" ], - "current_commit_message": "✨ cli: Add a command to give summary of all instructions", - "use_emojis": true + "current_commit_message": "🚀 cli: Empty specific attributes from .gitgo before pushing it on github", + "use_emojis": true, + "commit_config": false } \ No newline at end of file diff --git a/bin/index.js b/bin/index.js index d863c7f..1a92cbd 100755 --- a/bin/index.js +++ b/bin/index.js @@ -15,6 +15,8 @@ const git = simpleGit(); const { jsonReader } = require("../lib/funcs/jsonReader.js"); const version = require("../package.json"); const chalk = require("chalk"); +const { exec } = require("child_process"); +const fs = require("fs"); clear(); @@ -151,8 +153,46 @@ program return; } cMsg = conf.current_commit_message; - git.commit(cMsg); - console.log("Files have be commited: " + cMsg); + if (conf.commit_config) { + conf.commit_config = false; + conf.current_commit_message = ""; + conf.current_branch = [""]; + conf.existing_branches = [""]; + conf.selected_commit_type = ""; + conf.current_issue.number = ""; + conf.current_issue.labels = [""]; + conf.current_issue.title = ""; + fs.writeFile("./.gitgo", JSON.stringify(conf, null, 2), (err) => { + if (err) console.log("Error writing file:", err); + }); + setTimeout(function () { + exec("git add ./.gitgo", (error, stdout, stderr) => { + if (error) { + console.log(`error: ${error.message}`); + return; + } + if (stderr) { + console.log(`stderr: ${stderr}`); + return; + } + }); + git.commit(cMsg); + console.log("Files have be commited: " + cMsg); + }, 1000); + } else { + exec("git reset -- ./.gitgo", (error, stdout, stderr) => { + if (error) { + console.log(`error: ${error.message}`); + return; + } + if (stderr) { + console.log(`stderr: ${stderr}`); + return; + } + }); + git.commit(cMsg); + console.log("Files have be commited: " + cMsg); + } }); } else { // checks if the directory is a git based repo or not diff --git a/lib/inquirer.js b/lib/inquirer.js index 692c1e3..d79cc45 100644 --- a/lib/inquirer.js +++ b/lib/inquirer.js @@ -120,6 +120,7 @@ module.exports = { return; } conf.use_emojis = emo; + conf.commit_config = true; fs.writeFile( "./.gitgo", JSON.stringify(conf, null, 2), @@ -170,6 +171,7 @@ module.exports = { return; } conf.use_emojis = emo; + conf.commit_config = true; fs.writeFile( "./.gitgo", JSON.stringify(conf, null, 2),