Skip to content

Commit

Permalink
fix(command): format input name when adding factory
Browse files Browse the repository at this point in the history
  • Loading branch information
neikvon committed Oct 13, 2020
1 parent a11fe88 commit c019085
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/commands/add.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { join } from 'path'
import { Fbi } from '../fbi'
import { Command } from '../core/command'
import { git, isGitUrl } from '../utils'
import { git, isGitUrl, formatName } from '../utils'

export default class CommandAdd extends Command {
id = 'add'
Expand Down Expand Up @@ -80,13 +80,14 @@ export default class CommandAdd extends Command {

gitUrl = gitUrl.endsWith('.git') ? gitUrl : `${gitUrl}.git`
const name = gitUrl.split('/').pop()?.replace('.git', '')

if (!name) {
this.error(`invalid url:`, gitUrl)
return null
}

return {
name,
name: formatName(name) as string,
url: gitUrl
}
}
Expand All @@ -106,7 +107,9 @@ export default class CommandAdd extends Command {
const _name = this.style.cyan(name)
const spinner = this.createSpinner(`Adding ${_name} from '${src}'`).start()
try {
await git.clone(`${src} ${dest}`)
await git.clone(`${src} ${dest}`, {
stdout: 'inherit'
})
spinner.succeed(`Added ${_name}`)
} catch (err) {
spinner.fail(`Failed to add ${name}`)
Expand Down

0 comments on commit c019085

Please sign in to comment.