Get started
@hulla/gittar
Copy a repository folder into a starter project, with a separate cache and an explicit refresh policy.
On this page
@hulla/gittar downloads a repository’s files over HTTPS and extracts them into a cache. Use it in a Bun script to fetch a starter project or a collection of templates.
You get the files at one revision, without a .git directory or commit history.
Build a template downloader that copies a repository to a local folder, then run it again to observe the cache.
import gittar from '@hulla/gittar'
const snapshot = await gittar({
url: 'hulladev/gittar',
branch: 'master',
outDir: './downloaded-template',
})
console.log(snapshot.files.length, snapshot.fromCache)The full repository goes into the cache. A separate outDir receives a copy. Add a subpath when you only need one directory.
| Policy | What a later call does |
|---|---|
commit (default) | Checks the remote branch and downloads if its commit changed. |
always | Downloads again, even when cached files exist. |
never | Uses existing cached files without checking the remote. Downloads on a cache miss. |
Read Caching and copying before building an updater. Use the reference to look up options, returned metadata, and error types.