Skip to content
This repository has been archived by the owner on Oct 26, 2019. It is now read-only.

Commit

Permalink
Create directories before trying to clone to them.
Browse files Browse the repository at this point in the history
  • Loading branch information
Blaine Schmeisser committed Jan 10, 2017
1 parent a6f9f28 commit a96e62e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
24 changes: 16 additions & 8 deletions app/lib/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const which = require('which')
const retry = require('./retry')
const installStatus = require('./installStatus')
const jetpack = require('fs-jetpack')
const mkdirp = require('mkdirp')
const path = require('path')

const git = (args, options) => {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -37,14 +39,20 @@ const clone = (name, packagePath) => {
if (status && jetpack.exists(packagePath)) return status
return retry(`git clone [${name}]`, () => {
const packageUrl = 'https://github.com/' + name + '.git'
return git(['clone', packageUrl, packagePath]).catch((err) => {
if (err.message.match(/already exists/i)) {
return // futher promises will resolve
} else if (err.message.match(/Repository not found/i)) {
throw new Error('Package "' + name + '" does not exist on github')
} else {
throw err
}
return new Promise((resolve, reject) => {
mkdirp(path.dirname(packagePath), (err) => {
err ? reject(err) : resolve()
})
}).then(() => {
return git(['clone', packageUrl, packagePath]).catch((err) => {
if (err.message.match(/already exists/i)) {
return // futher promises will resolve
} else if (err.message.match(/Repository not found/i)) {
throw new Error('Package "' + name + '" does not exist on github')
} else {
throw err
}
})
}).then(() => {
return installStatus.set(name, 'cloned')
})
Expand Down
9 changes: 3 additions & 6 deletions app/lib/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ const pull = (name, packagePath) => {

const download = (remote, local) => {
return new Promise((resolve, reject) => {
const dir = path.dirname(local)
if (!fs.existsSync(dir)) {
mkdirp(dir, resolve)
} else {
resolve()
}
mkdirp(path.dirname(local), (err) => {
err ? reject(err) : resolve()
})
}).then(() => {
return new Promise((resolve, reject) => {
request(remote)
Expand Down

0 comments on commit a96e62e

Please sign in to comment.