diff --git a/generate/templates/templates/nodegit.js b/generate/templates/templates/nodegit.js index 15b8f322c..c22d7d999 100644 --- a/generate/templates/templates/nodegit.js +++ b/generate/templates/templates/nodegit.js @@ -1,5 +1,5 @@ var _ = require("lodash"); -var promisify = require("promisify-node"); +var util = require("util"); var rawApi; // Attempt to load the production release first, if it fails fall back to the @@ -16,6 +16,8 @@ catch (ex) { rawApi = require("../build/Debug/nodegit.node"); } +var promisify = fn => fn && util.promisify(fn); // jshint ignore:line + // For disccussion on why `cloneDeep` is required, see: // https://github.com/facebook/jest/issues/3552 // https://github.com/facebook/jest/issues/3550 @@ -132,9 +134,6 @@ importExtension("filter_registry"); {% endeach %} /* jshint ignore:end */ -// Wrap asynchronous methods to return promises. -promisify(exports); - // Set version. exports.version = require("../package").version; diff --git a/lib/commit.js b/lib/commit.js index c91245f04..8eb561e58 100644 --- a/lib/commit.js +++ b/lib/commit.js @@ -21,17 +21,12 @@ Commit.lookup = LookupWrapper(Commit); * @param {Number} n * @return {Commit} */ -Commit.prototype.parent = function(n, callback) { +Commit.prototype.parent = function(n) { var repo = this.repo; return _parent.call(this, n).then(p => { p.repo = repo; - - if (typeof callback === "function") { - callback(null, p); - } - return p; - }, callback); + }); }; /** @@ -43,10 +38,10 @@ Commit.prototype.parent = function(n, callback) { * @param {String} message_encoding * @param {String} message * @param {Tree|Oid} tree - * @param {Oid} callback + * @return {Oid} */ Commit.prototype.amend = function ( - updateRef, author, committer, message_encoding, message, tree, callback) { + updateRef, author, committer, message_encoding, message, tree) { var repo = this.repo; var _this = this; var treePromise; @@ -244,11 +239,10 @@ Commit.prototype.date = function() { * and its parent(s). * * @async - * @param {Function} callback * @return {Array} an array of diffs */ -Commit.prototype.getDiff = function(callback) { - return this.getDiffWithOptions(null, callback); +Commit.prototype.getDiff = function() { + return this.getDiffWithOptions(null); }; /** @@ -257,10 +251,9 @@ Commit.prototype.getDiff = function(callback) { * * @async * @param {Object} options - * @param {Function} callback * @return {Array} an array of diffs */ -Commit.prototype.getDiffWithOptions = function(options, callback) { +Commit.prototype.getDiffWithOptions = function(options) { var commit = this; return commit.getTree().then(function(thisTree) { @@ -278,13 +271,7 @@ Commit.prototype.getDiffWithOptions = function(options, callback) { return Promise.all(diffs); }); - }).then(function(diffs) { - if (typeof callback === "function") { - callback(null, diffs); - } - - return diffs; - }, callback); + }); }; /** @@ -295,16 +282,10 @@ Commit.prototype.getDiffWithOptions = function(options, callback) { * @param {String} path * @return {TreeEntry} */ -Commit.prototype.getEntry = function(path, callback) { +Commit.prototype.getEntry = function(path) { return this.getTree().then(function(tree) { - return tree.getEntry(path).then(function(entry) { - if (typeof callback === "function") { - callback(null, entry); - } - - return entry; - }); - }, callback); + return tree.getEntry(path); + }); }; /** @@ -312,17 +293,11 @@ Commit.prototype.getEntry = function(path, callback) { * * @async * @param {number} limit Optional amount of parents to return. - * @param {Function} callback * @return {Array} array of commits */ -Commit.prototype.getParents = function(limit, callback) { +Commit.prototype.getParents = function(limit) { var parents = []; - // Shift arguments. - if (typeof limit === "function") { - callback = limit; - } - // If no limit was set, default to the maximum parents. limit = typeof limit === "number" ? limit : this.parentcount(); limit = Math.min(limit, this.parentcount()); @@ -335,13 +310,7 @@ Commit.prototype.getParents = function(limit, callback) { } // Wait for all parents to complete, before returning. - return Promise.all(parents).then(function(parents) { - if (typeof callback === "function") { - callback(null, parents); - } - - return parents; - }, callback); + return Promise.all(parents); }; /** @@ -367,8 +336,8 @@ Commit.prototype.getSignature = function(field) { * @async * @return {Tree} */ -Commit.prototype.getTree = function(callback) { - return this.repo.getTree(this.treeId(), callback); +Commit.prototype.getTree = function() { + return this.repo.getTree(this.treeId()); }; /** @@ -415,7 +384,7 @@ Commit.prototype.history = function() { /** * Get the specified parent of the commit. - * + * * @param {number} the position of the parent, starting from 0 * @async * @return {Commit} the parent commit at the specified position diff --git a/lib/filter_registry.js b/lib/filter_registry.js index 76dfba573..e51f901d5 100644 --- a/lib/filter_registry.js +++ b/lib/filter_registry.js @@ -4,11 +4,10 @@ var normalizeOptions = NodeGit.Utils.normalizeOptions; var FilterRegistry = NodeGit.FilterRegistry; var _register = FilterRegistry.register; -var _unregister = FilterRegistry.unregister; // register should add filter by name to dict and return // Override FilterRegistry.register to normalize Filter -FilterRegistry.register = function(name, filter, priority, callback) { +FilterRegistry.register = function(name, filter, priority) { // setting default value of attributes if (filter.attributes === undefined) { filter.attributes = ""; @@ -17,26 +16,10 @@ FilterRegistry.register = function(name, filter, priority, callback) { filter = normalizeOptions(filter, NodeGit.Filter); if (!filter.check || !filter.apply) { - return callback(new Error( + return Promise.reject(new Error( "ERROR: please provide check and apply callbacks for filter" )); } - return _register(name, filter, priority) - .then(function(result) { - if (typeof callback === "function") { - callback(null, result); - } - return result; - }, callback); -}; - -FilterRegistry.unregister = function(name, callback) { - return _unregister(name) - .then(function(result) { - if (typeof callback === "function") { - callback(null, result); - } - return result; - }, callback); + return _register(name, filter, priority); }; diff --git a/lib/odb.js b/lib/odb.js deleted file mode 100644 index 8bbd15a62..000000000 --- a/lib/odb.js +++ /dev/null @@ -1,15 +0,0 @@ -var NodeGit = require("../"); - -var Odb = NodeGit.Odb; - -var _read = Odb.prototype.read; - -Odb.prototype.read = function(oid, callback) { - return _read.call(this, oid).then(function(odbObject) { - if (typeof callback === "function") { - callback(null, odbObject); - } - - return odbObject; - }, callback); -}; diff --git a/lib/repository.js b/lib/repository.js index d3b6ade2d..69f011ae0 100644 --- a/lib/repository.js +++ b/lib/repository.js @@ -331,15 +331,11 @@ function performRebase( are hit. This may be set to null * @return {String} Path of the git repository */ -Repository.discover = function(startPath, acrossFs, ceilingDirs, callback) { +Repository.discover = function(startPath, acrossFs, ceilingDirs) { return _discover(startPath, acrossFs, ceilingDirs) .then(function(foundPath) { - foundPath = path.resolve(foundPath); - if (typeof callback === "function") { - callback(null, foundPath); - } - return foundPath; - }, callback); + return path.resolve(foundPath); + }); }; // Override Repository.initExt to normalize initoptions @@ -551,7 +547,7 @@ Repository.prototype.createBlobFromBuffer = function(buffer) { * @return {Oid} The oid of the commit */ Repository.prototype.createCommit = function( - updateRef, author, committer, message, tree, parents, callback) { + updateRef, author, committer, message, tree, parents) { var repo = this; var promises = []; @@ -586,13 +582,7 @@ Repository.prototype.createCommit = function( parents.length, parents ); - }).then(function(commit) { - if (typeof callback === "function") { - callback(null, commit); - } - - return commit; - }, callback); + }); }; /** @@ -768,8 +758,7 @@ Repository.prototype.createCommitOnHead = function( filesToAdd, author, committer, - message, - callback) { + message) { var repo = this; @@ -808,7 +797,7 @@ Repository.prototype.createCommitOnHead = function( parent ); }); - }, callback); + }); }; /** @@ -819,7 +808,7 @@ Repository.prototype.createCommitOnHead = function( * @param {String} name the name of the tag * @return {Reference} */ -Repository.prototype.createLightweightTag = function(oid, name, callback) { +Repository.prototype.createLightweightTag = function(oid, name) { var repository = this; return Commit.lookup(repository, oid) @@ -852,7 +841,7 @@ Repository.prototype.createRevWalk = function() { * annotated tag * @return {Tag} */ -Repository.prototype.createTag = function(oid, name, message, callback) { +Repository.prototype.createTag = function(oid, name, message) { const repository = this; let signature = null; @@ -866,7 +855,7 @@ Repository.prototype.createTag = function(oid, name, message, callback) { return Tag.create(repository, name, commit, signature, message, 0); }) .then((tagOid) => { - return repository.getTag(tagOid, callback); + return repository.getTag(tagOid); }); }; @@ -986,28 +975,16 @@ Repository.prototype.discardLines = */ Repository.prototype.fetch = function( remote, - fetchOptions, - callback) + fetchOptions) { var repo = this; - function finallyFn(error) { - if (typeof callback === "function") { - callback(error); - } - } - return repo.getRemote(remote) .then(function(remote) { return remote.fetch(null, fetchOptions, "Fetch from " + remote) .then(function() { return remote.disconnect(); }); - }) - .then(finallyFn) - .catch(function(error) { - finallyFn(error); - throw error; }); }; @@ -1018,12 +995,8 @@ Repository.prototype.fetch = function( * @async * @param {Object|FetchOptions} fetchOptions Options for the fetch, includes * callbacks for fetching - * @param {Function} callback */ -Repository.prototype.fetchAll = function( - fetchOptions, - callback) -{ +Repository.prototype.fetchAll = function(fetchOptions) { var repo = this; function createCallbackWrapper(fn, remote) { @@ -1070,11 +1043,6 @@ Repository.prototype.fetchAll = function( return repo.fetch(remote, wrappedFetchOptions); }); }, Promise.resolve()); - }) - .then(function() { - if (typeof callback === "function") { - callback(); - } }); }; @@ -1094,18 +1062,13 @@ Repository.prototype.fetchheadForeach = function(callback) { * @param {String|Oid} String sha or Oid * @return {Blob} */ -Repository.prototype.getBlob = function(oid, callback) { +Repository.prototype.getBlob = function(oid) { var repository = this; return Blob.lookup(repository, oid).then(function(blob) { blob.repo = repository; - - if (typeof callback === "function") { - callback(null, blob); - } - return blob; - }, callback); + }); }; /** @@ -1116,8 +1079,8 @@ Repository.prototype.getBlob = function(oid, callback) { * or Branch Ref * @return {Reference} */ -Repository.prototype.getBranch = function(name, callback) { - return this.getReference(name, callback); +Repository.prototype.getBranch = function(name) { + return this.getReference(name); }; /** @@ -1128,8 +1091,8 @@ Repository.prototype.getBranch = function(name, callback) { * or Branch Ref * @return {Commit} */ -Repository.prototype.getBranchCommit = function(name, callback) { - return this.getReferenceCommit(name, callback); +Repository.prototype.getBranchCommit = function(name) { + return this.getReferenceCommit(name); }; /** @@ -1139,16 +1102,10 @@ Repository.prototype.getBranchCommit = function(name, callback) { * @param {String|Oid} String sha or Oid * @return {Commit} */ -Repository.prototype.getCommit = function(oid, callback) { +Repository.prototype.getCommit = function(oid) { var repository = this; - return Commit.lookup(repository, oid).then(function(commit) { - if (typeof callback === "function") { - callback(null, commit); - } - - return commit; - }, callback); + return Commit.lookup(repository, oid); }; /** @@ -1168,12 +1125,12 @@ Repository.prototype.getCurrentBranch = function() { * @async * @return {Commit} */ -Repository.prototype.getHeadCommit = function(callback) { +Repository.prototype.getHeadCommit = function() { var repo = this; return Reference.nameToId(repo, "HEAD") .then(function(head) { - return repo.getCommit(head, callback); + return repo.getCommit(head); }) .catch(function() { return null; @@ -1186,8 +1143,8 @@ Repository.prototype.getHeadCommit = function(callback) { * @async * @return {Commit} */ -Repository.prototype.getMasterCommit = function(callback) { - return this.getBranchCommit("master", callback); +Repository.prototype.getMasterCommit = function() { + return this.getBranchCommit("master"); }; /** @@ -1198,28 +1155,20 @@ Repository.prototype.getMasterCommit = function(callback) { * or Branch Ref * @return {Reference} */ -Repository.prototype.getReference = function(name, callback) { +Repository.prototype.getReference = function(name) { var repository = this; return Reference.dwim(this, name).then(function(reference) { if (reference.isSymbolic()) { return reference.resolve().then(function(reference) { reference.repo = repository; - - if (typeof callback === "function") { - callback(null, reference); - } - return reference; - }, callback); - } else { - reference.repo = repository; - if (typeof callback === "function") { - callback(null, reference); - } - return reference; + }); } - }, callback); + + reference.repo = repository; + return reference; + }); }; /** @@ -1230,18 +1179,12 @@ Repository.prototype.getReference = function(name, callback) { * or Branch Ref * @return {Commit} */ -Repository.prototype.getReferenceCommit = function(name, callback) { +Repository.prototype.getReferenceCommit = function(name) { var repository = this; return this.getReference(name).then(function(reference) { - return repository.getCommit(reference.target()).then(function(commit) { - if (typeof callback === "function") { - callback(null, commit); - } - - return commit; - }); - }, callback); + return repository.getCommit(reference.target()); + }); }; /** @@ -1268,44 +1211,24 @@ Repository.prototype.getReferenceNames = function(type) { * * @async * @param {String|Remote} remote - * @param {Function} callback * @return {Remote} The remote object */ -Repository.prototype.getRemote = function(remote, callback) { +Repository.prototype.getRemote = function(remote) { if (remote instanceof NodeGit.Remote) { - return Promise.resolve(remote).then(function(remoteObj) { - if (typeof callback === "function") { - callback(null, remoteObj); - } - - return remoteObj; - }, callback); + return Promise.resolve(remote); } - return NodeGit.Remote.lookup(this, remote).then(function(remoteObj) { - if (typeof callback === "function") { - callback(null, remoteObj); - } - - return remoteObj; - }, callback); + return NodeGit.Remote.lookup(this, remote); }; /** * Lists out the remotes in the given repository. * * @async -* @param {Function} Optional callback * @return {Object} Promise object. */ -Repository.prototype.getRemoteNames = function(callback) { - return Remote.list(this).then(function(remotes) { - if (typeof callback === "function") { - callback(null, remotes); - } - - return remotes; - }, callback); +Repository.prototype.getRemoteNames = function() { + return Remote.list(this); }; /** @@ -1371,17 +1294,13 @@ Repository.prototype.getStatusExt = function(opts) { * @async * @return {Array} */ -Repository.prototype.getSubmoduleNames = function(callback) { +Repository.prototype.getSubmoduleNames = function() { var names = []; var submoduleCallback = function(submodule, name, payload) { names.push(name); }; return Submodule.foreach(this, submoduleCallback).then(function() { - if (typeof callback === "function") { - callback(null, names); - } - return names; }); }; @@ -1393,18 +1312,13 @@ Repository.prototype.getSubmoduleNames = function(callback) { * @param {String|Oid} String sha or Oid * @return {Tag} */ -Repository.prototype.getTag = function(oid, callback) { +Repository.prototype.getTag = function(oid) { var repository = this; return Tag.lookup(repository, oid).then(function(reference) { reference.repo = repository; - - if (typeof callback === "function") { - callback(null, reference); - } - return reference; - }, callback); + }); }; /** @@ -1414,22 +1328,18 @@ Repository.prototype.getTag = function(oid, callback) { * @param {String} Short or full tag name * @return {Tag} */ -Repository.prototype.getTagByName = function(name, callback) { +Repository.prototype.getTagByName = function(name) { var repo = this; name = ~name.indexOf("refs/tags/") ? name : "refs/tags/" + name; - return Reference.nameToId(repo, name).then(function(oid) { - return Tag.lookup(repo, oid).then(function(reference) { + return Reference.nameToId(repo, name) + .then(function(oid) { + return Tag.lookup(repo, oid); + }).then(function(reference) { reference.repo = repo; - - if (typeof callback === "function") { - callback(null, reference); - } - return reference; }); - }, callback); }; /** @@ -1439,18 +1349,13 @@ Repository.prototype.getTagByName = function(name, callback) { * @param {String|Oid} String sha or Oid * @return {Tree} */ -Repository.prototype.getTree = function(oid, callback) { +Repository.prototype.getTree = function(oid) { var repository = this; return Tree.lookup(repository, oid).then(function(tree) { tree.repo = repository; - - if (typeof callback === "function") { - callback(null, tree); - } - return tree; - }, callback); + }); }; /** @@ -1632,19 +1537,12 @@ Repository.prototype.rebaseBranches = function( * @async * @return {Index} */ -Repository.prototype.refreshIndex = function(callback) { +Repository.prototype.refreshIndex = function() { var repo = this; repo.setIndex(); // clear the index - return repo.index() - .then(function(index) { - if (typeof callback === "function") { - callback(null, index); - } - - return index; - }, callback); + return repo.index(); }; /** diff --git a/lib/revert.js b/lib/revert.js index 84c05b5c9..d6ef9b705 100644 --- a/lib/revert.js +++ b/lib/revert.js @@ -24,8 +24,7 @@ Revert.commit = function( revert_commit, our_commit, mainline, - merge_options, - callback + merge_options ) { merge_options = normalizeOptions(merge_options, NodeGit.MergeOptions); @@ -37,14 +36,7 @@ Revert.commit = function( our_commit, mainline, merge_options - ) - .then(function(result) { - if (typeof callback === "function") { - callback(null, result); - } - - return result; - }, callback); + ); }; /** diff --git a/lib/revwalk.js b/lib/revwalk.js index a12d9f7f4..7787fc89b 100644 --- a/lib/revwalk.js +++ b/lib/revwalk.js @@ -119,7 +119,7 @@ Revwalk.prototype.walk = function(oid, callback) { this.push(oid); function walk() { - revwalk.next().done(function(oid) { + revwalk.next().then(function(oid) { if (!oid) { if (typeof callback === "function") { return callback(); diff --git a/lib/tree.js b/lib/tree.js index 43af49656..1067fa3f2 100644 --- a/lib/tree.js +++ b/lib/tree.js @@ -11,7 +11,6 @@ var Treebuilder = NodeGit.Treebuilder; * @async * @param {Repository} repo The repo that the tree lives in * @param {String|Oid|Tree} id The tree to lookup -* @param {Function} callback * @return {Tree} */ Tree.lookup = LookupWrapper(Tree); @@ -33,11 +32,10 @@ Tree.prototype.builder = function() { * Diff two trees * @async * @param {Tree} tree to diff against - * @param {Function} callback * @return {Diff} */ -Tree.prototype.diff = function(tree, callback) { - return this.diffWithOptions(tree, null, callback); +Tree.prototype.diff = function(tree) { + return this.diffWithOptions(tree, null); }; /** @@ -45,17 +43,10 @@ Tree.prototype.diff = function(tree, callback) { * @async * @param {Tree} tree to diff against * @param {Object} options - * @param {Function} callback * @return {Diff} */ -Tree.prototype.diffWithOptions = function(tree, options, callback) { - return Diff.treeToTree(this.repo, tree, this, options).then(function(diff) { - if (typeof callback === "function") { - callback(null, diff); - } - - return diff; - }, callback); +Tree.prototype.diffWithOptions = function(tree, options) { + return Diff.treeToTree(this.repo, tree, this, options); }; /** @@ -104,17 +95,12 @@ Tree.prototype.entryByName = function(name) { * @param {String} filePath * @return {TreeEntry} */ -Tree.prototype.getEntry = function(filePath, callback) { +Tree.prototype.getEntry = function(filePath) { var tree = this; return this.entryByPath(filePath).then(function(entry) { entry.parent = tree; entry.dirtoparent = path.dirname(filePath); - - if (typeof callback === "function") { - callback(null, entry); - } - return entry; }); }; @@ -171,7 +157,8 @@ Tree.prototype.walk = function(blobsOnly) { if (entry.isTree()) { total++; - entry.getTree(bfs); + entry.getTree() + .then(result => bfs(null, result), bfs); } }); diff --git a/lib/tree_entry.js b/lib/tree_entry.js index b9bc0fd72..a978de9a3 100644 --- a/lib/tree_entry.js +++ b/lib/tree_entry.js @@ -7,14 +7,8 @@ var TreeEntry = NodeGit.TreeEntry; * @async * @return {Blob} */ -TreeEntry.prototype.getBlob = function(callback) { - return this.parent.repo.getBlob(this.id()).then(function(blob) { - if (typeof callback === "function") { - callback(null, blob); - } - - return blob; - }, callback); +TreeEntry.prototype.getBlob = function() { + return this.parent.repo.getBlob(this.id()); }; /** @@ -22,18 +16,13 @@ TreeEntry.prototype.getBlob = function(callback) { * @async * @return {Tree} */ -TreeEntry.prototype.getTree = function(callback) { +TreeEntry.prototype.getTree = function() { var entry = this; return this.parent.repo.getTree(this.id()).then(function(tree) { tree.entry = entry; - - if (typeof callback === "function") { - callback(null, tree); - } - return tree; - }, callback); + }); }; /** @@ -89,7 +78,7 @@ TreeEntry.prototype.oid = function() { * Returns the path for this entry. * @return {String} */ -TreeEntry.prototype.path = function(callback) { +TreeEntry.prototype.path = function() { var dirtoparent = this.dirtoparent || ""; return path.join(this.parent.path(), dirtoparent, this.name()); }; diff --git a/package-lock.json b/package-lock.json index de03d41a3..b71c90c33 100644 --- a/package-lock.json +++ b/package-lock.json @@ -162,11 +162,6 @@ "dev": true, "optional": true }, - "asap": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", - "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" - }, "asn1": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", @@ -3913,14 +3908,6 @@ } } }, - "nodegit-promise": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/nodegit-promise/-/nodegit-promise-4.0.0.tgz", - "integrity": "sha1-VyKxhPLfcycWEGSnkdLoQskWezQ=", - "requires": { - "asap": "~2.0.3" - } - }, "nopt": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", @@ -4357,14 +4344,6 @@ "dev": true, "optional": true }, - "promisify-node": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/promisify-node/-/promisify-node-0.3.0.tgz", - "integrity": "sha1-tLVaz5D6p9K4uQyjlomQhsAwYM8=", - "requires": { - "nodegit-promise": "~4.0.0" - } - }, "proto-list": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/proto-list/-/proto-list-1.2.4.tgz", diff --git a/package.json b/package.json index 9f7193d22..96539ef15 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,6 @@ "nan": "^2.14.0", "node-gyp": "^4.0.0", "node-pre-gyp": "^0.13.0", - "promisify-node": "~0.3.0", "ramda": "^0.25.0", "tar-fs": "^1.16.3" }, diff --git a/test/tests/revert.js b/test/tests/revert.js index 46263e7b9..e213dec28 100644 --- a/test/tests/revert.js +++ b/test/tests/revert.js @@ -37,15 +37,16 @@ describe("Revert", function() { var fileStats = fs.statSync(path.join(repoPath, fileName)); assert.ok(fileStats.isFile()); - Revert.revert(test.repository, test.firstCommit, new RevertOptions()) + return Revert.revert(test.repository, test.firstCommit, new RevertOptions()) .then(function() { try { fs.statSync(path.join(repoPath, fileName)); - assert.fail("Working directory was not reverted"); - } - catch (error) { - // pass + } catch (e) { + // we expect this not to exist + return; } + + assert.fail("Working directory was not reverted"); }); }); diff --git a/test/tests/tree.js b/test/tests/tree.js index 98c5959e9..68765bf74 100644 --- a/test/tests/tree.js +++ b/test/tests/tree.js @@ -31,11 +31,11 @@ describe("Tree", function() { }); it("gets an entry by name", - function(done) { - this.commit.getTree().then(function(tree) { + function() { + return this.commit.getTree().then(function(tree) { var entry = tree.entryByName("README.md"); assert(entry); - }).done(done); + }); }); it("updates a tree", function () { diff --git a/test/tests/tree_entry.js b/test/tests/tree_entry.js index 086a4f8d2..f62f374f0 100644 --- a/test/tests/tree_entry.js +++ b/test/tests/tree_entry.js @@ -61,7 +61,7 @@ describe("TreeEntry", function() { }); }); - it("provides the full path when the entry came from a tree", function(done) { + it("provides the full path when the entry came from a tree", function() { var testTree = function(tree, _dir) { var dir = _dir || "", testPromises = []; @@ -82,10 +82,7 @@ describe("TreeEntry", function() { }; return this.commit.getTree() - .then(testTree) - .done(function() { - done(); - }); + .then(testTree); }); it("provides the blob representation of the entry", function() {