Skip to content

Commit

Permalink
Determine repo details using ./git
Browse files Browse the repository at this point in the history
This closes #13
  • Loading branch information
leo committed Dec 31, 2016
1 parent 77d3d26 commit ce7e0a9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion bin/release.js
Expand Up @@ -179,7 +179,7 @@ const checkReleaseStatus = async project => {
}

githubConnection = await connect()
repoDetails = getRepo(project.repository)
repoDetails = await getRepo(project.repository)

handleSpinner.create('Checking if release already exists')

Expand Down
1 change: 0 additions & 1 deletion lib/connect.js
Expand Up @@ -99,7 +99,6 @@ const requestToken = async () => {

module.exports = async () => {
let token = await loadToken()
token = false

if (!token) {
handleSpinner.create('Opening GitHub authentication page...')
Expand Down
26 changes: 12 additions & 14 deletions lib/repo.js
@@ -1,26 +1,24 @@
// Packages
const isURL = require('is-url')
const parseRepo = require('github-url-to-object')
const git = require('git-state')
const repoName = require('git-repo-name')
const repoUser = require('git-username')

// Ours
const handleSpinner = require('./spinner')

exports.getRepo = field => {
if (typeof field === 'string') {
if (isURL(field)) {
return parseRepo(field)
exports.getRepo = () => new Promise(resolve => {
repoName((err, repo) => {
if (err) {
handleSpinner.fail('Could not determine GitHub repository.')
return
}

return parseRepo(`github:${field}`)
}

if (field.url) {
return parseRepo(field.url)
}
const details = {repo}
details.user = repoUser()

handleSpinner.fail('Could not determine GitHub repository.')
}
resolve(details)
})
})

exports.branchSynced = async () => new Promise(resolve => {
const path = process.cwd()
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -49,11 +49,11 @@
"chalk": "^1.1.3",
"configstore": "^2.1.0",
"git-commits": "^1.2.0",
"git-repo-name": "^0.6.0",
"git-state": "^3.1.0",
"git-username": "^0.4.0",
"github": "^7.1.0",
"github-url-to-object": "^2.2.6",
"inquirer": "^2.0.0",
"is-url": "^1.2.2",
"open": "0.0.5",
"ora": "^0.4.0",
"pluralize": "^3.1.0",
Expand Down

0 comments on commit ce7e0a9

Please sign in to comment.