インストール
bash
1yarn add nodegit @types/nodegit
2
typescript: title=nodegit.ts
1
2import Git, { Clone, Commit, Repository } from 'nodegit'
3
4const cloneRepository = async (
5 githubUrl: string,
6 directoryName: string
7): Promise<Repository> => {
8 return await Clone.clone(githubUrl, directoryName);
9};
10
11const getMostResetntCommit = (repo: Repository) => {
12 return repo.getBranchCommit('master');
13};
14
15const getCommitMessage = (commit: Commit) => {
16 return commit.message();
17};
18
19
20
SSH Authentication を使ってクローンする