Skip to content

Commit fec768f

Browse files
committed
Update details-for-tree-entry.js
1 parent 3b2d68b commit fec768f

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

examples/details-for-tree-entry.js

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
1-
var nodegit = require("../");
2-
var path = require("path");
1+
const nodegit = require("../");
2+
const path = require("path");
33

44
/**
55
* This shows how to get details from a tree entry or a blob
66
**/
77

8-
nodegit.Repository.open(path.resolve(__dirname, "../.git"))
9-
.then(function(repo) {
10-
return repo.getTree("e1b0c7ea57bfc5e30ec279402a98168a27838ac9")
11-
.then(function(tree) {
12-
var treeEntry = tree.entryByIndex(0);
8+
(async () => {
9+
const repo = await nodegit.Repository.open(path.resolve(__dirname, "../.git"));
10+
const tree = await repo.getTree("e1b0c7ea57bfc5e30ec279402a98168a27838ac9");
11+
const treeEntry = tree.entryByIndex(0);
12+
13+
// Tree entry doesn't have any data associated with the actual entry
14+
// To get that we need to get the index entry that this points to
15+
const index = await repo.refreshIndex();
16+
const indexEntry = index.getByPath(treeEntry.path());
1317

14-
// Tree entry doesn't have any data associated with the actual entry
15-
// To get that we need to get the index entry that this points to
16-
return repo.refreshIndex().then(function(index) {
17-
var indexEntry = index.getByPath(treeEntry.path());
18+
// With the index entry we can now view the details for the tree entry
19+
console.log("Entry path: " + indexEntry.path);
20+
console.log("Entry time in seconds: " + indexEntry.mtime.seconds());
21+
console.log("Entry oid: " + indexEntry.id.toString());
22+
console.log("Entry size: " + indexEntry.fileSize);
23+
24+
console.log("Done!");
25+
})();
1826

19-
// With the index entry we can now view the details for the tree entry
20-
console.log("Entry path: " + indexEntry.path);
21-
console.log("Entry time in seconds: " + indexEntry.mtime.seconds());
22-
console.log("Entry oid: " + indexEntry.id.toString());
23-
console.log("Entry size: " + indexEntry.fileSize);
24-
});
25-
});
26-
})
27-
.done(function() {
28-
console.log("Done!");
29-
});

0 commit comments

Comments
 (0)