Skip to content

Conversation

@WalczakPaulo
Copy link
Member

No description provided.

package.json Outdated
]
],
"dependencies": {
"rimraf": "^3.0.0"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to dev dependencies

import { prompt } from 'inquirer'
import * as colors from 'colors'

const fs = require('fs')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use fs-extra for all file system operations and rename next line from fsExtra to fs - every method from fs is supported by fs-extra, so you can use it as a drop-in replacement.

this.botonicApiService.beforeExit()
await exec('mv ../.botonic.json .')
try {
await fsExtra.move('../.botonic.json', './botonic.json')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's a typo or not, it's .botonic.json to botonic.json without dot at the beginning but in the original it just moves the file one directory up - is that what we want?

const util = require('util')
const ora = require('ora')
const exec = util.promisify(require('child_process').exec)
const fsExtra = require('fs-extra')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to fs

import * as colors from 'colors'

const fs = require('fs')
const fsExtra = require('fs-extra')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really related to this line but rather whole block - notice that there are import statements above it, but below that there are requires.... I think it should be consistent (you can use imports everywhere - it's TypeScript), but there are a lot of other code quality issues that linter would report so I'm not sure if you should be handling that or not.

}
let bot = bots.filter(b => b.name === botName)[0]
if (bot == undefined) {
if (bot === undefined) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really fishy to be honest... Generally bot should always return either some kind of "bot" object or undefined but you don't really check undefined like that ever. And here we actually only want this bot object. I'd suggest switching contents of if and else blocks and use if (bot).

}
]).then((inp: any) => {
if (inp.signupConfirmation == choices[1]) return this.askLogin()
if (inp.signupConfirmation === choices[1]) return this.askLogin()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personal preference but I don't really like inline if/else, you could replace this whole block with ternary.

await this.botonicApiService.getMoreBots(bots, nextBots)
}
// Show the current bot in credentials at top of the list
let first_id = this.botonicApiService.bot.id

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is everything in camelCase (or so I thought) and this thing is in snake_case? Again not sure if you should even care about this but yeah...

}
// Show the current bot in credentials at top of the list
let first_id = this.botonicApiService.bot.id
bots.sort(function(x, y) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use arrow function

@paolostyle
Copy link

Looks good to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants