@begit/core
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -1,2 +0,2 @@ | ||
import { fetchLatestCommit, getFileWithHash, cachedir, cacheFileName, fetchTarball, toFile } from './chunk-V4GSRNM7.js'; | ||
import { fetchLatestCommit, getFileWithHash, cachedir, cacheFileName, fetchTarball, toFile } from './chunk-5RFXWD6Y.js'; | ||
import { join } from 'path'; | ||
@@ -3,0 +3,0 @@ import { extract } from 'tar/extract'; |
@@ -1,3 +0,3 @@ | ||
export { begitDir, cacheFileName, cachedir, fetchLatestCommit, fetchTarball, getFileWithHash, getMostRecentCachedCommit, homedir, toFile } from './chunk-V4GSRNM7.js'; | ||
export { begitDir, cacheFileName, cachedir, fetchLatestCommit, fetchTarball, getFileWithHash, getMostRecentCachedCommit, homedir, toFile } from './chunk-5RFXWD6Y.js'; | ||
//# sourceMappingURL=utils.js.map | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "@begit/core", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Blazingly fast tool for cloning git repositories, with no reliance on local `git`, or `tar` installs", | ||
@@ -5,0 +5,0 @@ "author": "Thomas Beer", |
@@ -8,9 +8,9 @@ # Begit | ||
await downloadRepo({ | ||
repo: { | ||
owner: "Tommypop2", | ||
name: "begit", | ||
branch: undefined, | ||
subdir: undefined, | ||
}, | ||
"cool_project", | ||
repo: { | ||
owner: "Tommypop2", | ||
name: "begit", | ||
branch: undefined, | ||
subdir: undefined, | ||
}, | ||
"cool_project", | ||
}); | ||
@@ -22,1 +22,39 @@ ``` | ||
Alternatively, `downloadAndExtract` could be used in place of `downloadRepo` to opt out of automatically attempting to handle errors | ||
## Providing a custom commit hash | ||
```ts | ||
import { downloadRepo } from "@begit/core"; | ||
const custom_hash = "9e4e51beb1ac76e6c37be1757f14b904617a2f9b"; | ||
await downloadRepo({ | ||
repo: { | ||
owner: "Tommypop2", | ||
name: "begit", | ||
branch: undefined, | ||
subdir: undefined, | ||
hash: custom_hash, | ||
}, | ||
"cool_project", | ||
}); | ||
``` | ||
## Fetching the most recent cached commit | ||
```ts | ||
import { downloadRepo } from "@begit/core"; | ||
const most_recent_hash = await getMostRecentCachedCommit("Tommypop2", "begit"); // string | undefined | ||
await downloadRepo({ | ||
repo: { | ||
owner: "Tommypop2", | ||
name: "begit", | ||
branch: undefined, | ||
subdir: undefined, | ||
hash: most_recent_hash, | ||
}, | ||
"cool_project", | ||
}); | ||
``` |
@@ -16,4 +16,19 @@ import { type PathLike } from "fs"; | ||
}; | ||
/** | ||
* Fetched the most recent commit hash of a Github repository | ||
* | ||
* @param owner Owner of repository | ||
* @param repo Repository name | ||
* @returns Most recent commit hash in repository | ||
*/ | ||
export declare const fetchLatestCommit: (owner: string, repo: string) => Promise<string>; | ||
export declare const getFileWithHash: (repoOwner: string, repoName: string, hash: string) => Promise<string>; | ||
/** | ||
* Gets the most recent commit hash of the repository from the local cache | ||
* | ||
* @param repoOwner Owner of repository | ||
* @param repoName Repository name | ||
* @returns Most recent commit hash of repository in cache, or `undefined` | ||
* if there is no cache entry for this repository | ||
*/ | ||
export declare const getMostRecentCachedCommit: (repoOwner: string, repoName: string) => Promise<{ | ||
@@ -20,0 +35,0 @@ hash: string; |
24079
213
59