Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit afd030d

Browse filesBrowse files
committed
Merge pull request #615 from heavyk/thenify-bluebird
bluebird promises + thenify
2 parents 090096b + e22fa5c commit afd030d
Copy full SHA for afd030d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

60 files changed

+198
-147
lines changed
Open diff view settings
Collapse file

‎examples/add-and-commit.js‎

Copy file name to clipboardExpand all lines: examples/add-and-commit.js
+3-8Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
var nodegit = require("../");
22
var path = require("path");
3-
var promisify = require("promisify-node");
4-
var fse = promisify(require("fs-extra"));
3+
var promisify = require("thenify-all");
4+
var fse = promisify(require("fs-extra"), ["ensureDir", "writeFile"]);
55
var fileName = "newfile.txt";
66
var fileContent = "hello world";
77
var directoryName = "salad/toast/strangerinastrangeland/theresnowaythisexists";
8-
// ensureDir is an alias to mkdirp, which has the callback with a weird name
9-
// and in the 3rd position of 4 (the 4th being used for recursion). We have to
10-
// force promisify it, because promisify-node won't detect it on its
11-
// own and assumes sync
12-
fse.ensureDir = promisify(fse.ensureDir);
138

149
/**
1510
* This example creates a certain file `newfile.txt`, adds it to the git
@@ -71,6 +66,6 @@ nodegit.Repository.open(path.resolve(__dirname, "../.git"))
7166

7267
return repo.createCommit("HEAD", author, committer, "message", oid, [parent]);
7368
})
74-
.done(function(commitId) {
69+
.then(function(commitId) {
7570
console.log("New Commit: ", commitId);
7671
});
Collapse file

‎examples/clone.js‎

Copy file name to clipboardExpand all lines: examples/clone.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var nodegit = require("../");
2-
var promisify = require("promisify-node");
3-
var fse = promisify(require("fs-extra"));
2+
var promisify = require("thenify-all");
3+
var fse = promisify(require("fs-extra"), ["remove"]);
44
var path = "/tmp/nodegit-clone-demo";
55

66
fse.remove(path).then(function() {
@@ -28,7 +28,7 @@ fse.remove(path).then(function() {
2828
entry = entryResult;
2929
return entry.getBlob();
3030
})
31-
.done(function(blob) {
31+
.then(function(blob) {
3232
console.log(entry.filename(), entry.sha(), blob.rawsize() + "b");
3333
console.log("========================================================\n\n");
3434
var firstTenLines = blob.toString().split("\n").slice(0, 10).join("\n");
Collapse file

‎examples/cloneFromGithubWith2Factor.js‎

Copy file name to clipboardExpand all lines: examples/cloneFromGithubWith2Factor.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var nodegit = require("../");
2-
var promisify = require("promisify-node");
3-
var fse = promisify(require("fs-extra"));
2+
var promisify = require("thenify-all");
3+
var fse = promisify(require("fs-extra"), ["remove"]);
44
var path = "/tmp/nodegit-github-2factor-demo";
55

66
var token = "{Your GitHub user token}";
@@ -35,7 +35,7 @@ var opts = {
3535

3636
fse.remove(path).then(function() {
3737
nodegit.Clone(repoUrl, path, opts)
38-
.done(function(repo) {
38+
.then(function(repo) {
3939
if (repo instanceof nodegit.Repository) {
4040
console.info("We cloned the repo!");
4141
}
Collapse file

‎examples/create-branch.js‎

Copy file name to clipboardExpand all lines: examples/create-branch.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ nodegit.Repository.open(path.resolve(__dirname, "../.git"))
1313
repo.defaultSignature(),
1414
"Created new-branch on HEAD");
1515
});
16-
}).done(function() {
16+
}).then(function() {
1717
console.log("All done!");
1818
});
Collapse file

‎examples/create-new-repo.js‎

Copy file name to clipboardExpand all lines: examples/create-new-repo.js
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
var nodegit = require("../");
22
var path = require("path");
3-
var promisify = require("promisify-node");
4-
var fse = promisify(require("fs-extra"));
3+
var promisify = require("thenify-all");
4+
var fse = promisify(require("fs-extra"), ["ensureDir", "writeFile"]);
55
var fileName = "newfile.txt";
66
var fileContent = "hello world";
77
var repoDir = "../../newRepo";
88

9-
fse.ensureDir = promisify(fse.ensureDir);
10-
119
var repository;
1210
var index;
1311

@@ -45,6 +43,6 @@ fse.ensureDir(path.resolve(__dirname, repoDir))
4543
// normal we don't get the head either, because there isn't one yet.
4644
return repository.createCommit("HEAD", author, committer, "message", oid, []);
4745
})
48-
.done(function(commitId) {
46+
.then(function(commitId) {
4947
console.log("New Commit: ", commitId);
5048
});
Collapse file

‎examples/details-for-tree-entry.js‎

Copy file name to clipboardExpand all lines: examples/details-for-tree-entry.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ nodegit.Repository.open(path.resolve(__dirname, "../.git"))
2424
});
2525
});
2626
})
27-
.done(function() {
27+
.then(function() {
2828
console.log("Done!");
2929
});
Collapse file

‎examples/diff-commits.js‎

Copy file name to clipboardExpand all lines: examples/diff-commits.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ nodegit.Repository.open(path.resolve(__dirname, "../.git"))
1818

1919
return commit.getDiff();
2020
})
21-
.done(function(diffList) {
21+
.then(function(diffList) {
2222
diffList.forEach(function(diff) {
2323
diff.patches().then(function(patches) {
2424
patches.forEach(function(patch) {
Collapse file

‎examples/fetch.js‎

Copy file name to clipboardExpand all lines: examples/fetch.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ nodegit.Repository.open(path.resolve(__dirname, "../.git"))
88
return nodegit.Cred.sshKeyFromAgent(userName);
99
}
1010
});
11-
}).done(function() {
11+
}).then(function() {
1212
console.log("It worked!");
1313
});
Collapse file

‎examples/general.js‎

Copy file name to clipboardExpand all lines: examples/general.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var nodegit = require("../");
22
var path = require("path");
3-
var Promise = require("nodegit-promise");
3+
var Promise = require("bluebird");
44
var oid;
55
var odb;
66
var repo;
@@ -362,6 +362,6 @@ nodegit.Repository.open(path.resolve(__dirname, "../.git"))
362362
return Promise.all(promises);
363363
})
364364

365-
.done(function() {
365+
.then(function() {
366366
console.log("Done!");
367367
});
Collapse file

‎examples/index-add-and-remove.js‎

Copy file name to clipboardExpand all lines: examples/index-add-and-remove.js
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
var nodegit = require("../");
22
var path = require("path");
3-
var Promise = require("nodegit-promise");
4-
var promisify = require("promisify-node");
5-
var fse = promisify(require("fs-extra"));
3+
var Promise = require("bluebird");
4+
var promisify = require("thenify-all");
5+
var fse = promisify(require("fs-extra"), ["writeFile"]);
66

77
nodegit.Repository.open(path.resolve(__dirname, "../.git"))
88
.then(function(repo) {
@@ -129,6 +129,6 @@ nodegit.Repository.open(path.resolve(__dirname, "../.git"))
129129
console.log("New files in index: " + newFiles.length);
130130
});
131131
});
132-
}).done(function() {
132+
}).then(function() {
133133
console.log("All done!");
134134
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.