Skip to content

Commit 0a9b455

Browse files
committed
printError bug fixed
1 parent 8ec5334 commit 0a9b455

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

cli.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ const ora = require('ora');
55
const parseChunk = require('./src/utils/parseChunk');
66
const { printError } = require('./src/utils/print');
77

8+
const questions = [
9+
{
10+
type: 'input',
11+
message: 'Enter your botToken:',
12+
name: 'botToken',
13+
},
14+
{
15+
type: 'input',
16+
message: 'Enter channel\'s username (without @):',
17+
name: 'channelUsername',
18+
},
19+
];
20+
821
const handleAnswers = (answers) => {
922
const { botToken, channelUsername } = answers;
1023
const url = `https://api.telegram.org/bot${botToken}/getChat?chat_id=@${channelUsername}`;
@@ -31,17 +44,6 @@ const handleError = (error) => {
3144
};
3245

3346
inquirer
34-
.prompt([
35-
{
36-
type: 'input',
37-
message: 'Enter your botToken:',
38-
name: 'botToken',
39-
},
40-
{
41-
type: 'input',
42-
message: 'Enter channel\'s username (without @):',
43-
name: 'channelUsername',
44-
},
45-
])
47+
.prompt(questions)
4648
.then(handleAnswers)
4749
.catch(handleError);

src/utils/print.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ const printWarning = (text) => console.warn(
66
);
77

88
const printError = (text) => console.error(
9-
'\x1b[31m', 'Invalid botToken or channel username provided!',
9+
'\x1b[33m', 'express-notify-telegram ==>',
10+
'\x1b[31m', text,
1011
);
1112

1213
module.exports = { printWarning, printError };

0 commit comments

Comments
 (0)