Skip to content

Commit c753353

Browse files
agg-shambhaviactions-user
authored andcommitted
🔧 general: Fix linting with prettier
1 parent 9668585 commit c753353

File tree

3 files changed

+149
-187
lines changed

3 files changed

+149
-187
lines changed

lib/funcs/commit-gen.js

Lines changed: 126 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -11,189 +11,154 @@ const suggestCommitMsgCb = (conf) => {
1111
const issue_number = conf.current_issue.number;
1212
const commitGuidelines = conf.commit_guidelines;
1313
const customBoolean = conf.custom_guidelines;
14-
const commitTypeContent = conf.selected_commit_type.match(/([A-Za-z\s\-]+)\w+/g).join().trim();
14+
const commitTypeContent = conf.selected_commit_type
15+
.match(/([A-Za-z\s\-]+)\w+/g)
16+
.join()
17+
.trim();
1518
const emojiBool = conf.use_emojis;
1619
var commitTypeEmoji;
1720
var commitGuideNum;
1821
var commitMsg;
1922
var commitPrefix;
2023

2124
const messageBlock = {
22-
"Initial commit" :
23-
{
24-
emoji : conf.emojis.initial_commit,
25-
prefix : ''
26-
},
27-
"Adding a new user-facing feature" :
28-
{
29-
emoji : conf.emojis.feature,
30-
prefix : 'feat'
31-
},
32-
"Improving UI" :
33-
{
34-
emoji : conf.emojis.ui,
35-
prefix : 'feat'
36-
},
37-
"Refactoring or improving code" :
38-
{
39-
emoji : conf.emojis.code_quality,
40-
prefix : 'chore'
41-
},
42-
"Improving performance" :
43-
{
44-
emoji : conf.emojis.security,
45-
prefix : 'chore'
46-
},
47-
"Updating configs" :
48-
{
49-
emoji : conf.emojis.config,
50-
prefix : 'chore'
51-
},
52-
"Improving accessibility" :
53-
{
54-
emoji : conf.emojis.accessibility,
55-
prefix : 'chore'
56-
},
57-
"Improving dev tools" :
58-
{
59-
emoji : conf.emojis.dev_tools,
60-
prefix : 'feat'
61-
},
62-
"Writing docs" :
63-
{
64-
emoji : conf.emojis.docs,
65-
prefix : 'chore'
66-
},
67-
"New release" :
68-
{
69-
emoji : conf.emojis.release,
70-
prefix : 'chore'
71-
},
72-
"Fixing a bug" :
73-
{
74-
emoji : conf.emojis.bug_fix,
75-
prefix : 'fix'
76-
},
77-
"Fixing a crash" :
78-
{
79-
emoji : conf.emojis.crash,
80-
prefix : 'fix'
81-
},
82-
"Removing code/files" :
83-
{
84-
emoji : conf.emojis.cleanup,
85-
prefix : 'chore'
86-
},
87-
"WIP" :
88-
{
89-
emoji : conf.emojis.wip,
90-
prefix : 'chore'
91-
},
92-
}
25+
"Initial commit": {
26+
emoji: conf.emojis.initial_commit,
27+
prefix: "",
28+
},
29+
"Adding a new user-facing feature": {
30+
emoji: conf.emojis.feature,
31+
prefix: "feat",
32+
},
33+
"Improving UI": {
34+
emoji: conf.emojis.ui,
35+
prefix: "feat",
36+
},
37+
"Refactoring or improving code": {
38+
emoji: conf.emojis.code_quality,
39+
prefix: "chore",
40+
},
41+
"Improving performance": {
42+
emoji: conf.emojis.security,
43+
prefix: "chore",
44+
},
45+
"Updating configs": {
46+
emoji: conf.emojis.config,
47+
prefix: "chore",
48+
},
49+
"Improving accessibility": {
50+
emoji: conf.emojis.accessibility,
51+
prefix: "chore",
52+
},
53+
"Improving dev tools": {
54+
emoji: conf.emojis.dev_tools,
55+
prefix: "feat",
56+
},
57+
"Writing docs": {
58+
emoji: conf.emojis.docs,
59+
prefix: "chore",
60+
},
61+
"New release": {
62+
emoji: conf.emojis.release,
63+
prefix: "chore",
64+
},
65+
"Fixing a bug": {
66+
emoji: conf.emojis.bug_fix,
67+
prefix: "fix",
68+
},
69+
"Fixing a crash": {
70+
emoji: conf.emojis.crash,
71+
prefix: "fix",
72+
},
73+
"Removing code/files": {
74+
emoji: conf.emojis.cleanup,
75+
prefix: "chore",
76+
},
77+
WIP: {
78+
emoji: conf.emojis.wip,
79+
prefix: "chore",
80+
},
81+
};
9382

9483
var details = messageBlock[commitTypeContent];
9584
commitPrefix = details.prefix;
96-
commitTypeEmoji = emoji.get(':'+details.emoji+':');
85+
commitTypeEmoji = emoji.get(":" + details.emoji + ":");
9786

98-
switch(commitGuidelines[0])
99-
{
100-
case `fix:`:
101-
commitGuideNum = 1;
87+
switch (commitGuidelines[0]) {
88+
case `fix:`:
89+
commitGuideNum = 1;
90+
break;
91+
case `fix #`:
92+
commitGuideNum = 2;
10293
break;
103-
case `fix #`:
104-
commitGuideNum = 2;
94+
case `...(fix #)`:
95+
commitGuideNum = 3;
10596
break;
106-
case `...(fix #)`:
107-
commitGuideNum = 3;
108-
break;
109-
default: commitGuideNum = 4;
97+
default:
98+
commitGuideNum = 4;
11099
}
111100

112-
if (customBoolean == false)
113-
{
114-
switch(commitGuideNum)
115-
{
116-
case 1:
117-
{
118-
if (emojiBool == true)
119-
{
120-
commitMsg = `${commitTypeEmoji} ${commitPrefix}: ${issue_title}`;
121-
conf.current_commit_message = commitMsg;
122-
123-
}
124-
else
125-
{
126-
commitMsg = `${commitPrefix}: ${issue_title}`;
127-
conf.current_commit_message = commitMsg;
128-
129-
}
130-
}
131-
break;
132-
case 2:
133-
{
134-
if (emojiBool == true)
135-
{
136-
commitMsg = `${commitTypeEmoji} fix #${issue_number} ${issue_title}`;
137-
conf.current_commit_message = commitMsg;
138-
139-
}
140-
else
141-
{
142-
commitMsg = `fix #${issue_number} ${issue_title}`;
143-
conf.current_commit_message = commitMsg;
144-
145-
}
146-
}
147-
break;
148-
case 3:
149-
{
150-
if (emojiBool == true)
151-
{
152-
commitMsg = `${commitTypeEmoji} ${issue_title} fix #${issue_number}`;
153-
conf.current_commit_message = commitMsg;
154-
155-
}
156-
else
157-
{
158-
commitMsg = `${issue_title} fix #${issue_number}`;
159-
conf.current_commit_message = commitMsg;
160-
}
161-
}
162-
}
163-
}
164-
else
165-
{
166-
var customPrefix = issue_labels.length>0? issue_labels[0]+":": '';
167-
if (emojiBool == true)
168-
{
169-
commitMsg = `${commitTypeEmoji} ${customPrefix} ${issue_title}`;
170-
conf.current_commit_message = commitMsg;
171-
101+
if (customBoolean == false) {
102+
switch (commitGuideNum) {
103+
case 1:
104+
{
105+
if (emojiBool == true) {
106+
commitMsg = `${commitTypeEmoji} ${commitPrefix}: ${issue_title}`;
107+
conf.current_commit_message = commitMsg;
108+
} else {
109+
commitMsg = `${commitPrefix}: ${issue_title}`;
110+
conf.current_commit_message = commitMsg;
172111
}
173-
else
174-
{
175-
commitMsg = `${customPrefix} ${issue_title}`;
176-
conf.current_commit_message = commitMsg;
177-
112+
}
113+
break;
114+
case 2:
115+
{
116+
if (emojiBool == true) {
117+
commitMsg = `${commitTypeEmoji} fix #${issue_number} ${issue_title}`;
118+
conf.current_commit_message = commitMsg;
119+
} else {
120+
commitMsg = `fix #${issue_number} ${issue_title}`;
121+
conf.current_commit_message = commitMsg;
178122
}
123+
}
124+
break;
125+
case 3: {
126+
if (emojiBool == true) {
127+
commitMsg = `${commitTypeEmoji} ${issue_title} fix #${issue_number}`;
128+
conf.current_commit_message = commitMsg;
129+
} else {
130+
commitMsg = `${issue_title} fix #${issue_number}`;
131+
conf.current_commit_message = commitMsg;
132+
}
133+
}
134+
}
135+
} else {
136+
var customPrefix = issue_labels.length > 0 ? issue_labels[0] + ":" : "";
137+
if (emojiBool == true) {
138+
commitMsg = `${commitTypeEmoji} ${customPrefix} ${issue_title}`;
139+
conf.current_commit_message = commitMsg;
140+
} else {
141+
commitMsg = `${customPrefix} ${issue_title}`;
142+
conf.current_commit_message = commitMsg;
143+
}
179144
}
180145
fs.writeFile("./.gitgo", JSON.stringify(conf, null, 2), (err) => {
181146
if (err) console.log("Error writing file:", err);
182147
});
183148
return commitMsg;
184-
}
149+
};
185150

186151
module.exports = {
187-
suggestCommitMsg:() => {
188-
setTimeout(()=>{
189-
reader.jsonReader('./.gitgo', (err, conf) => {
190-
if (err) {
191-
console.log(err)
192-
return
193-
}
194-
const retVal = suggestCommitMsgCb(conf);
195-
})
196-
}, 6000);
152+
suggestCommitMsg: () => {
153+
setTimeout(() => {
154+
reader.jsonReader("./.gitgo", (err, conf) => {
155+
if (err) {
156+
console.log(err);
157+
return;
158+
}
159+
const retVal = suggestCommitMsgCb(conf);
160+
});
161+
}, 6000);
197162
},
198-
suggestCommitMsgCb
199-
}
163+
suggestCommitMsgCb,
164+
};

lib/funcs/generate.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ var pos = require("retext-pos");
66
var keywords = require("retext-keywords");
77
var toString = require("nlcst-to-string");
88

9-
10-
const suggestBranchNmCb = (conf) =>
11-
{
9+
const suggestBranchNmCb = (conf) => {
1210
var branch_names = [];
1311
issue_title = conf.current_issue.title;
1412
retext().use(pos).use(keywords).process(conf.current_issue.title, done);
@@ -64,20 +62,19 @@ const suggestBranchNmCb = (conf) =>
6462
}
6563
}
6664
return branch_names;
67-
}
68-
65+
};
6966

7067
module.exports = {
71-
branchName:() => {
72-
setTimeout(()=>{
73-
reader.jsonReader('./.gitgo', (err, conf) => {
74-
if (err) {
75-
console.log(err)
76-
return
77-
}
78-
const retVal = suggestBranchNmCb(conf);
79-
})
80-
}, 6000);
68+
branchName: () => {
69+
setTimeout(() => {
70+
reader.jsonReader("./.gitgo", (err, conf) => {
71+
if (err) {
72+
console.log(err);
73+
return;
74+
}
75+
const retVal = suggestBranchNmCb(conf);
76+
});
77+
}, 6000);
8178
},
82-
suggestBranchNmCb
83-
}
79+
suggestBranchNmCb,
80+
};

tests/generate.test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
const reader = require("../lib/funcs/jsonReader");
2-
const {suggestBranchNmCb} = require('../lib/funcs/generate')
2+
const { suggestBranchNmCb } = require("../lib/funcs/generate");
33

4-
test('Suggests Commit Message Callback', () => {
5-
reader.jsonReader('../.gitgo', (err, conf) => {
6-
if (err) {
7-
return
8-
}
9-
expect(suggestBranchNmCb(conf).not.toBe(undefined))
10-
})
11-
})
4+
test("Suggests Commit Message Callback", () => {
5+
reader.jsonReader("../.gitgo", (err, conf) => {
6+
if (err) {
7+
return;
8+
}
9+
expect(suggestBranchNmCb(conf).not.toBe(undefined));
10+
});
11+
});

0 commit comments

Comments
 (0)