diff --git a/spec/git-repository-async-spec.coffee b/spec/git-repository-async-spec.coffee index 0eba6a4f4..068756a72 100644 --- a/spec/git-repository-async-spec.coffee +++ b/spec/git-repository-async-spec.coffee @@ -34,8 +34,8 @@ fdescribe "GitRepositoryAsync", -> it "repo is null when no repository is found", -> repo = GitRepositoryAsync.open(path.join(temp.dir, 'nogit.txt')) - waitsFor -> - repo._opening is false + waitsForPromise {shouldReject: true}, -> + repo.repoPromise runs -> expect(repo.repo).toBe null diff --git a/src/git-repository-async.js b/src/git-repository-async.js index aec474f45..f3916eb19 100644 --- a/src/git-repository-async.js +++ b/src/git-repository-async.js @@ -3,26 +3,20 @@ const Git = require('nodegit') const path = require('path') +// GitUtils is temporarily used for ::relativize only, because I don't want +// to port it just yet. TODO: remove +const GitUtils = require('git-utils') + module.exports = class GitRepositoryAsync { static open (path) { // QUESTION: Should this wrap Git.Repository and reject with a nicer message? - return new GitRepositoryAsync(Git.Repository.open(path)) + return new GitRepositoryAsync(path) } - constructor (openPromise) { + constructor (path) { this.repo = null - // this could be replaced with a function - this._opening = true - - // Do I use this outside of tests? - openPromise.then((repo) => { - this.repo = repo - this._opening = false - }).catch((e) => { - this._opening = false - }) - - this.repoPromise = openPromise + this._gitUtilsRepo = GitUtils.open(path) // TODO remove after porting ::relativize + this.repoPromise = Git.Repository.open(path) } getPath () {