Skip to content

Commit

Permalink
feat($core): use ora
Browse files Browse the repository at this point in the history
close #2
  • Loading branch information
2nthony committed Jun 14, 2019
1 parent 4e0bf26 commit 6416374
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ const cac = require('cac')
const path = require('path')
const fs = require('fs')
const spawn = require('cross-spawn')
const ora = require('ora')
const parseArgs = require('../utils/parseArgs')
const logger = require('../utils/logger')
const matcher = require('multimatch')
const kleur = require('kleur')

module.exports = class Core {
constructor() {
Expand Down Expand Up @@ -79,19 +81,22 @@ module.exports = class Core {
const matched = matcher(this.getBranch(options), branches)

matched.forEach(branch => {
const args = options.remotes
const spinner = ora(`Deleting${this.text(branch)}`)
spinner.start()
const args = this.isRemotes
? ['push', options.scope, `:${branch}`]
: ['branch', branch, '-D']
const ps = spawn.sync('git', args)
if (ps.status === 0) {
logger.success(
`Deleted${options.remotes ? ' remote' : ''} branch`,
`\`${branch}\``
)
spinner.succeed(`Deleted${this.text(branch)}`)
}
})
}

text(branch) {
return `${this.isRemotes ? ' remotes' : ''} branch ` + kleur.magenta(branch)
}

run() {
this.cli.runMatchedCommand()
}
Expand Down

0 comments on commit 6416374

Please sign in to comment.