diff --git a/lib/index.js b/lib/index.js index 0486b9c..5331716 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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() { @@ -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() }