|
1 | | -var nodegit = require("../"); |
2 | | -var path = require("path"); |
| 1 | +const nodegit = require("../"); |
| 2 | +const path = require("path"); |
3 | 3 |
|
4 | 4 | /** |
5 | 5 | * This shows how to get details from a tree entry or a blob |
6 | 6 | **/ |
7 | 7 |
|
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()); |
13 | 17 |
|
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 | +})(); |
18 | 26 |
|
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