|
1 | | -var nodegit = require("../"), |
2 | | - path = require("path"); |
| 1 | +const nodegit = require("../"); |
| 2 | +const path = require("path"); |
3 | 3 |
|
4 | 4 | // This example opens a certain file, `README.md`, at a particular commit, |
5 | 5 | // and prints the first 10 lines as well as some metadata. |
6 | | -var _entry; |
7 | | -nodegit.Repository.open(path.resolve(__dirname, "../.git")) |
8 | | - .then(function(repo) { |
9 | | - return repo.getCommit("59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5"); |
10 | | - }) |
11 | | - .then(function(commit) { |
12 | | - return commit.getEntry("README.md"); |
13 | | - }) |
14 | | - .then(function(entry) { |
15 | | - _entry = entry; |
16 | | - return _entry.getBlob(); |
17 | | - }) |
18 | | - .then(function(blob) { |
19 | | - console.log(_entry.name(), _entry.sha(), blob.rawsize() + "b"); |
20 | | - console.log("========================================================\n\n"); |
21 | | - var firstTenLines = blob.toString().split("\n").slice(0, 10).join("\n"); |
22 | | - console.log(firstTenLines); |
23 | | - console.log("..."); |
24 | | - }) |
25 | | - .done(); |
| 6 | + |
| 7 | +(async () => { |
| 8 | + const repo = await nodegit.Repository.open(path.resolve(__dirname, "../.git")); |
| 9 | + const commit = await repo.getCommit("59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5"); |
| 10 | + const entry = await commit.getEntry("README.md"); |
| 11 | + const blob = await entry.getBlob(); |
| 12 | + |
| 13 | + console.log(entry.name(), entry.sha(), blob.rawsize() + "b"); |
| 14 | + console.log("========================================================\n\n"); |
| 15 | + const firstTenLines = blob.toString().split("\n").slice(0, 10).join("\n"); |
| 16 | + console.log(firstTenLines); |
| 17 | + console.log("..."); |
| 18 | +})(); |
| 19 | + |
0 commit comments