closeheat
Version:
Static Website Hosting with CMS without touching your code.
31 lines (25 loc) • 774 B
text/coffeescript
Promise = require 'bluebird'
_ = require 'lodash'
Git = require 'git-wrapper'
module.exports =
class GitRepository
: (opts) =>
().then (resp) =>
return _.assign(opts, repository: true) if resp.exists
().then ->
_.assign(opts, repository: true)
: (url) ->
new Promise (resolve, reject) =>
new Git().exec 'init', (err, resp) ->
return reject(err) if err
resolve(resp)
: ->
new Promise (resolve, reject) =>
new Git().exec 'remote', ['--verbose'], (err, resp) ->
if err
if err.message.match(/Not a git repository/)
return resolve(exists: false)
else
return resolve(exists: true)
else
resolve(exists: true)