Skip to content

Commit

Permalink
git refactor the the dir variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Kachulio1 committed Aug 1, 2019
1 parent 16db8be commit 704624f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/commands/clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const path = require('path')
const findUp = require('find-up')
const execa = require('execa')
const Listr = require('listr')
let dir = ''
let directory = ''
const tasks = new Listr([
{
title: 'Finding Directory',
Expand Down Expand Up @@ -36,12 +36,9 @@ const tasks = new Listr([
}

try {
let repoName = url.match(/([^/]+)\.git/g)[0].split('.')[0]
await execa('git', [
'clone',
`${url}`,
`${dir + '/' + name}/${repoName}`,
])
// the regex matches the name of the repo
directory += name + '/' + url.match(/([^/]+)\.git/g)[0].split('.')[0]
await execa('git', ['clone', `${url}`, `${directory}`])
} catch (error) {
if (
error.stderr.includes('already exists and is not an empty directory')
Expand Down

0 comments on commit 704624f

Please sign in to comment.