Skip to content

Fix github action workflow & linting errors #21

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"no-plusplus": "error",
"eqeqeq": ["error", "always"],
"quotes": ["error", "double"],
"semi": ["error", "always"]
"semi": ["error", "always"],
"space-before-function-paren": ["error", "never"]
}
}
15 changes: 8 additions & 7 deletions .github/lint.yml → .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
name: linter

on:
push:
branches:
- master
- main
pull_request:
branches:
- "*"
branches: [main]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16

- name: Install Dependencies
run: npm install
Expand Down
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": false
"singleQuote": false,
"trailingComma": "none"
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "A minimalist approach toward git commits to keep things simple.",
"main": "./bin/index.js",
"scripts": {
"lint": "eslint ."
"lint": "eslint .",
"fix": "eslint . --fix"
},
"bin": {
"mct": "bin/index.js"
Expand Down
32 changes: 14 additions & 18 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@ import {
getStagedFiles,
checkIfRepoisGit,
getUnstagedFiles,
stageFiles,
stageFiles
} from "./commands.js";

function logOption(title, description) {
return chalk.bgWhite(title) + " - " + description;
}

async function cli() {
const [isGit, stagedFiles] = await Promise.all([
checkIfRepoisGit(),
getStagedFiles(),
getStagedFiles()
]);
if (isGit && !stagedFiles) {
await promptToCommit();
Expand Down Expand Up @@ -61,15 +57,15 @@ const promptToCommit = async () => {
if (styledList.length < 1) {
console.log(chalk.bgRed("No changes made since last commit!"));
}
return await inquirer
await inquirer
.prompt([
{
name: "list",
message:
"Select the files you want to add with, and use (CTRL + D to exit)",
type: "checkbox",
choices: styledList,
},
choices: styledList
}
])
.then((answer) => {
if (answer.list.length < 1) {
Expand All @@ -92,7 +88,7 @@ const promptToCommit = async () => {
console.log(chalk.bgGreenBright("✅ Files Added"));
addCommit();
})
.catch((err) => {
.catch(() => {
console.log(
chalk.bgRed("⛔️ Oops, that was not supposed to happen") +
chalk.bgGrey("If that happens again, please raise an issue")
Expand All @@ -101,8 +97,8 @@ const promptToCommit = async () => {
});
};

const addCommit = async () => {
return await inquirer
async function addCommit() {
await inquirer
.prompt([
{
name: "type",
Expand All @@ -118,20 +114,20 @@ const addCommit = async () => {
"📝 docs",
"🎨 style",
"🛠 config",
"📦 misc",
],
"📦 misc"
]
},
{
name: "message",
message: "Write a commit message ✍️ : ",
type: "input",
},
type: "input"
}
])
.then((answer) => {
const message = `${answer.type}: ${answer.message}`;
console.log("\n");

if (answer.message == "") {
if (answer.message === "") {
console.log(chalk.bgRed("⛔️ Message can't be empty"));
process.exit(0);
} else if (!answer.message.includes(" ")) {
Expand All @@ -151,6 +147,6 @@ const addCommit = async () => {

commitFiles(message);
});
};
}

export default cli;
2 changes: 1 addition & 1 deletion src/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { logExec } from "./helper.js";
export function checkIfRepoisGit() {
return new Promise((resolve, reject) => {
exec("git rev-parse --is-inside-work-tree", (err, stdout, stderr) => {
if (stdout == "true\n") resolve(stdout);
if (stdout === "true\n") resolve(stdout);
if (stderr.includes("not a git repository")) {
console.log("\n\n");
console.log(
Expand Down